1

I am having trouble with changing the style of the LOF using titletoc. Everything works fine but the left parameter (i.e. the first parameter in the square brackets containing a length measure) of the \titlecontents{figure} command does not have any effect (it seems to be 0pt regardless of the value I provide). However, it works for chapter, section, and subsection. Is this a known bug or am I too stupid?

The misalignmentis shown in the picture:

BUUUG

I would like to have Figure aligned with Section.

Please find a MWE below.

\documentclass[a4paper]{article}

\usepackage{titletoc}


\contentsmargin{0pc}

% Section
\titlecontents{section}
[2.25pc]
{}
{\hspace*{-.75pc}\makebox[0pt][r]{\thecontentslabel}\hspace*{.75pc}}
{}
{\hspace{.5pc}\raisebox{.3ex}{$\scriptstyle\cdot$}\hspace{.5pc}\thecontentspage}

% Figures
\titlecontents{figure}
[2.25pc]
{\raggedright}
{\contentslabel{2.25pc}}
{}
{\hspace{.5pc}\raisebox{.3ex}{$\scriptstyle\cdot$}\hspace{.5pc}\thecontentspage}


\begin{document}

\tableofcontents
\listoffigures

\section{Section}
\begin{figure}
    \caption{Figure}
\end{figure}

\end{document}
  • Please complete your code to a full but minimal document. We can't compile it, as it is. Thanks. – LaRiFaRi Aug 11 '14 at 10:47
2

It seems to work fine for me if I delete the \raggedright command. Then I just used the same code you used for Section and it aligns just like you wanted.

\titlecontents{figure}
[2.25pc]
{}
{\hspace*{-.75pc}\makebox[0pt][r]{\thecontentslabel}\hspace*{.75pc}}
{}
{\hspace{.5pc}\raisebox{.3ex}{$\scriptstyle\cdot$}\hspace{.5pc}\thecontentspage}

But then the numbers don't align, but you can fix it by changing the hspace distances in the last line.

  • Thank you, that solved my problem. However, I still don't understand what \raggedright messed up; I moved it to the end of the second parameter, which seems to work. – Dan Aug 11 '14 at 15:28
  • You're welcome. I am not sure what you wanted to do with raggedright, but the place where you put it in is used for global formatting for the whole entry and you basically told the entry to go to the left side. – Gilean0709 Aug 11 '14 at 15:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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