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 am currently adapting the \part command to customize the table of contents as follows [code directly extracted from the book.cls class]:

\def\@part[#1]#2{%
    \ifnum \c@secnumdepth >-2\relax%
      \refstepcounter{part}%
      \addcontentsline{toc}{part}{\texorpdfstring{%
      \setlength\fboxsep{2pt}%
      \noindent\protect\colorbox{ocre!20}{\strut\protect\parbox[c][][c]{\ecart}%
      {\color{ocre!70}\bfseries\protect\centering\thepart}}\hskip6pt\colorbox{ocre!40}%
      {\strut\protect\parbox[c][][c]{\linewidth-4\fboxsep-\ecart-6pt}{\color{white}%
      \protect\centering\MakeUppercase{#1}}}}{#1}}%
    \else%
...

I am not providing the rest of the code which is quite long but the result is shown below: enter image description here

It is quite clear that the accented letter è affects the vertical alignment of the title within its box. Is there a way to avoid that? I would be happy with a vertical alignment that ignores accented letters. Otherwise, the \vphantom command is a possibility.

share|improve this question

1 Answer 1

up vote 4 down vote accepted

Hard to test without a working example but normally the \strut would be enough to cover the accented letters however you have used \parbox[c] so the text is vertically centred so moves down if accents are added. If you used [b] or [t] (which are the same for a one line box) then the text would align on the baseline so not move when there is an accent.

Alternatively you can hide the vertical size of the content by adding \smash

\leavevmode\protect\smash{\MakeUppercase{#1}}}
share|improve this answer
    
yes, but I want to keep the vertically centred title so the [c] option is fine. I just would like the accent to be ignored by the vertical alignment. –  pluton Mar 30 '13 at 23:43
    
OK, adding plan b... –  David Carlisle Mar 30 '13 at 23:46
    
ok, thanks. I tried but it yields quite unexpected results. It looks to me that the \vphantom{Ép} command associated with a \parbox[b][][b]{...} command aligning at the bottom is a good compromise. I wanted to avoid the \vphantom but it probably cannot be avoided. –  pluton Mar 31 '13 at 0:13
    
You are using the form of \parbox where you specify the height but not specifying the height, is that intended? –  David Carlisle Mar 31 '13 at 0:21
    
good question. I am not sure why I use this version. I thought it was the only one? –  pluton Mar 31 '13 at 0:27

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.