GeneralIndent Problem in Table of Contents

LaTeX specific issues not fitting into one of the other forums of this category.
rotarydial
Posts: 1
Joined: Mon Apr 12, 2010 2:29 pm

Indent Problem in Table of Contents

Post by rotarydial »

gmedina, thank you for your previous help on this topic. Here is where things break down for me. If I change the font of the LOT entries, the indentation is incorrect. Note lines 3-6 in the following code; they are the only change from one of your examples. Tossing this into pdflatex produces a LOT entry with incorrect line wrapping. Any ideas?

Code: Select all

\documentclass{report}
\usepackage{tocloft}
\renewcommand\cfttabfont{
	\fontfamily{phv}
	\fontsize{12pt}{10pt}
	\selectfont}
\newlength\mylength
\settowidth\mylength{Table}
\addtolength\cfttabnumwidth{\mylength}
\renewcommand\cfttabpresnum{Table }
\begin{document}
\listoftables               
\begin{table}[!ht]
  \centering
  \rule{4cm}{3cm}% to simulate a table
  \caption{Some long, very long test text which should span at least one line in the list of tables}
  \label{tab:test}
\end{table}
\end{document}

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Indent Problem in Table of Contents

Post by gmedina »

rotarydial wrote:gmedina, thank you for your previous help on this topic...
You are welcome!
rotarydial wrote:...Here is where things break down for me. If I change the font of the LOT entries, the indentation is incorrect. Note lines 3-6 in the following code; they are the only change from one of your examples. Tossing this into pdflatex produces a LOT entry with incorrect line wrapping. Any ideas?
Simply remove any blank spaces within \fontfamily, \fontsize, and \selectfont; it is also advisable to apply the font modification to calculate the \mylength length:

Code: Select all

\documentclass{report}
\usepackage{tocloft}

\renewcommand\cfttabfont{%
   \fontfamily{phv}\fontsize{12pt}{10pt}\selectfont}
\newlength\mylength
\settowidth\mylength{\cfttabfont Table}
\addtolength\cfttabnumwidth{\mylength}
\renewcommand\cfttabpresnum{Table\ }

\begin{document}
\listoftables               
\begin{table}[!ht]
  \centering
  \rule{4cm}{3cm}% to simulate a table
  \caption{Some long, very long test text which should span at least one line in the list of tables}
  \label{tab:test}
\end{table}
\end{document}
Edit: I corrected the last part of my message, regarding \mylength.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
Post Reply