Definizione Stile dei Titoli

  • Creatore
    Topic
  • #57906
    Up
    0
    Down
    ::


    Salve a tutti,

    ho un un problema con la definizione degli stili per i titoli. Vorrei avere la dimensione della numerazione che si centri e si adatti dinamicamente al crescere del numero di righe del testo del titolo.

    Vi sottopongo nel seguito i due stili con cui sto “giocando” e che presentano il problema:

    `
    \definefont[BigFontOne][Sans sa 3]

    \setupcolors[state=start] % otherwise you get greyscale

    %definizione di un colore
    \definecolor[headingcolor][r=0.4,b=0.4,g=0.4]
    \definecolor[textheadcolor][r=0.3,b=0.3,g=0.3]
    \definecolor[numberheadcolor][r=0,b=0.7,g=0]

    %Coloriamo i titoli
    %\setuphead[section,chapter,subject,subsection]
    \setuphead[section,chapter,subject,subsection][numbercolor=numberheadcolor, textcolor=textheadcolor]

    %font del capitolo
    %\setuphead[chapter][numberstyle=\BigFontOne,textstyle={\ss\bfd},%style={\ss\bfd}, before={}, after={\nowhitespace\hairline\blank[2*line]}]

    \setuphead[chapter]
    [
    numberstyle=\BigFontOne,
    textstyle={\ss\bfd},
    before={},
    after={\nowhitespace\color[darkred]\hl[38]\blank[2*line]}
    ]

    \setuphead[section,subject]
    [
    %numberstyle=\BigFontTwo\bf,
    %textstyle={\ss\bfc},
    style={\ss\bfc},
    before={\bigskip},
    after={\nowhitespace\color[darkred]\hl[38]\blank} %\hairline
    ]

    \setuphead[subsubject,subsection]
    [
    %numberstyle=\BigFontTwo\bf,
    %textstyle={\ss\bfc},
    style={\ss\bfb},
    before={\bigskip},
    after={\nowhitespace\color[darkred]\hl[38]\blank} %\hairline
    ]

    \starttext
    \chapter{foo dsfdsf fdsf dsfdsf dsf fdsf f dsf ds f dsf ds f dsf dsf f w fds f ds fds f sdf dsf }
    \section{goo}
    hello
    \stoptext
    `

    e
    `
    \def\BookchapterCommand#1#2{\framed[frame=off,rightframe=off]{\hbox{#1}\space}\framed[frame=off,leftframe=on]{\space\vbox{#2}}}
    \setuphead[chapter][command=\BookchapterCommand,page=chapter,numbercolor=red,alternative=inmargin,numberstyle=\ss\bfd]
    \setupcolors[state=start]
    \setupcolor[rgb]
    \definecolor[lightred][r=0.8,g=0.85,b=1]

    \def\SectionCommand#1#2%
    {\framed
    [frame=off,
    width=\textwidth,
    align={right},
    background=color,
    backgroundcolor=lightred]
    {\hbox to.011\textwidth{}\hbox to.05\textwidth{\strut#1}\quad
    \vtop{\hsize\dimexpr\hsize-.061\textwidth-1em\relax\begstrut#2
    \endstrut}}}

    \setuphead[section][command=\SectionCommand,numbercolor=red]

    \def\SubsectionCommand#1#2%
    {\framed
    [frame=off,
    width=\textwidth,
    align={right},
    background=color,
    backgroundcolor=lightgray]
    {\hbox to.011\textwidth{\strut#1}\vtop{\hsize\dimexpr\hsize-.011\textwidth-1em\relax\begstrut#2
    \endstrut}}}

    \setuphead[subsection][command=\SubsectionCommand,number=no,style=\ss]

    \setuphead[subsubsection][command=,style=slanted,number=no,before={\blank[big]},before={\testpage[1]},after=\nowhitespace]

    \starttext
    \chapter{foo}
    \section{goo}
    hello
    \stoptext

    \starttext

    \chapter{test cxvxvdfgdf dfsds fg d dfg df gdfhghf vb chdfc cffbgdfgdg}

    fdsfsfdsf

    \section{test vbcvbcxvd dfdf df s fs s dzs xz x sd s fs fs f sf sf s fs df sdf scx xz cxz c xzc zxc z f zsf sf d fd f dzv cz v cv cv xcv xc vcx}
    sfsdfdsfdf
    dsfdsfsdfdsfdsfdsfds

    \subsection{test}

    fgddsgdfgdfgdf

    \stoptext
    `

    Grazie

Visualizzazione 2 filoni di risposte
  • Autore
    Risposte
    • #57907
      Up
      0
      Down
      ::


      Guarda
      http://wiki.contextgarden.net/Titles
      Formatting Titles with \setuphead

      I vari
      command,
      numbercommand,
      textcommand

      dovrebbero far al caso tuo.
      La mia idea è usare command#1#2: metti in una \vbox il titolo #2 e trovi ht+dp
      metti il numero #1 in una seconda scatola con altezza ht+dp con \vfill prima e dopo in modo da centrare il contenuto, poi piazzi le scatole.

    • #57908
      Up
      0
      Down
      ::


      come faccio a trovare ht+dp?

      Scusami ma non sono molto pratico di context……

    • #57909
      Up
      0
      Down
      ::

      come faccio a trovare ht+dp?

      Scusami ma non sono molto pratico di context……

      \htdp<>
      `\starttext
      \newbox\MyBox
      \setbox\MyBox=\vbox{\hsize=3em foo\crlf goo}
      \the\htdp\MyBox\crlf
      ht+dp=\the\dimexpr \ht\MyBox +\dp\MyBox\relax\crlf
      ht=\the\dimexpr \ht\MyBox +0\dp\MyBox\relax\crlf
      dp=\the\dimexpr 0\ht\MyBox +\dp\MyBox\relax\crlf
      \ruledvbox{\unvbox\MyBox}
      \stoptext
      `

Visualizzazione 2 filoni di risposte
  • Devi essere connesso per rispondere a questo topic.

Go to top