Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I would to get the chapter number tall n-times the chapter name in order to have a better proportion between the two elements. Why I get errors and how can I fix that behaviour?

I thought something like this to include it:

\setbox4\hbox{\resizebox*{!}{\myheight}{\hspace{10pt}}}
\edef\hchapterspace{\the\wd4}

And use \hchapterspace

but I get: Package graphics Error: Division by 0 }

So the simplest way is:

...\hspace{10pt}\vline\hspace{10pt}}\ }{0pt}

but is the same thing to use {10pt} as \titleformat argument?


\documentclass[headinclude,footinclude]{scrbook}
\usepackage[eulerchapternumbers,pdfspacing]{classicthesis}
\usepackage{arsclassica}
\usepackage{lipsum}

\setbox10\hbox{\normalfont\Large\sffamily\spacedallcaps{\chaptername}}

\setbox20\hbox{\resizebox*{!}{\dimexpr\ht10*3\relax}{\chapterNumber\thechapter}}

\titleformat{\chapter}[block]%
        {\normalfont\Large\sffamily}%
        {{\color{halfgray}\box20%
        \hspace{10pt}\vline}  }{10pt}%
        {\spacedallcaps}

\begin{document}

\chapter{graphic test}
\lipsum[1-3]

\end{document}
share|improve this question
    
You forgot to load graphic[sx] package for resizebox. Also are you sure it's safe to use box 20? –  David Carlisle Dec 12 '12 at 19:38

1 Answer 1

up vote 7 down vote accepted

enter image description here

\documentclass[headinclude,footinclude]{scrbook}
\usepackage[eulerchapternumbers,pdfspacing]{classicthesis}
\usepackage{arsclassica,graphicx}
\usepackage{lipsum}

\setbox0\hbox{\normalfont\Large\sffamily\spacedallcaps{\chaptername}}
\edef\myheight{\the\dimexpr 3\ht0\relax}


\titleformat{\chapter}[block]%
        {\normalfont\Large\sffamily}%
        {\color{halfgray}\resizebox*{!}{\myheight}{\chapterNumber\thechapter
        \hspace{10pt}\vline}}{10pt}%
        {\spacedallcaps}

\begin{document}
\refstepcounter{chapter}

\chapter{graphic test}
\lipsum[1-3]

\end{document}

It is only safe to use boxes 0 2 4 6 8 as local scratch registers and you need to use them locally you can not assume that if you set it at one place the box has a usable value later in the document. Also you did not want a box at all for the chapter number that boxed the text when the counter was at 0 and so using the box in the chapter heading would not give the chapter number even if box20 had been safe to use.


Comment on the updated question about horizontal spacing. If you add the space after the resizebox or (I suspect, equivalently) in the following argument of \titleformat then the space added will be the space specified. If on the other hand you add the space before the closing } of the \resizebox then the space will be scaled in proportion to the scaling of the number, so if the \resizebox ends up scaling by (say) 3.1 times then \hspace{10pt} will produce 31pt of white space in the output. The choice is entirely up to you which you feel a more natural specification.

share|improve this answer
    
With your code I get: Process exited with error(s) –  FormlessCloud Dec 12 '12 at 21:43
    
If I comment \show\chapterNumber the error go away... –  FormlessCloud Dec 12 '12 at 21:55
    
oops:-) that isn't an error of course but your ide might think it is, yes it's just debugging I'll delete it from the answer –  David Carlisle Dec 12 '12 at 22:03
    
Is it also possible include this {10pt} space (after \vline) in the resize box? –  FormlessCloud Dec 14 '12 at 10:29
    
That's an argument to titleformat isn't it? –  David Carlisle Dec 14 '12 at 10:41

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.