GeneralAdding Prefixes to LoF and LoT Entries

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
bkarpuz
Posts: 124
Joined: Thu Dec 18, 2008 4:53 pm

Adding Prefixes to LoF and LoT Entries

Post by bkarpuz »

Dear LC members,

in the list of figures and list of tables, my output only includes tags, captions and the page numbers of the figures and tables.
List of Figures
1.1 The graph of the sigma function . . . . . . 1
1.2 The graph of the delta function. . . . . . . 1
However, I need to add a prefix before the tags of the members of the list with bold font as follows.
List of Figures
Prefix for figures 1.1 The graph of the sigma function . . . . . . 1
Prefix for figures 1.2 The graph of the delta function. . . . . . . 1
Also a similar case for the list of tables applies.
Is that possible?

Best regards.
bkarpuz

Recommended reading 2024:

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

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

bkarpuz
Posts: 124
Joined: Thu Dec 18, 2008 4:53 pm

Adding Prefixes to LoF and LoT Entries

Post by bkarpuz »

Dear LC members,

I have found the solution and I want to share it with those who may need.
After declaring the package »etoolbox«

Code: Select all

\makeatletter
\patchcmd{\@caption}{\csname the#1\endcsname}{\textbf{\csname fnum@#1\endcsname}}{}{}
\renewcommand*\l@figure{\@dottedtocline{1}{1.5em}{3.7em}} %the 3rd argument depends on the lenght of your prefix
\renewcommand*\l@table{\@dottedtocline{1}{1.5em}{5em}} %the 3rd argument depends on the lenght of your prefix
\makeatother
In my case, I also use the following Turkish translations.

Code: Select all

\def\listfigurename{\centering \c{S}EK\.{I}LLER D\.{I}Z\.{I}N\.{I}}
\def\listtablename{\centering \c{C}\.{I}ZELGELER D\.{I}Z\.{I}N\.{I}}
\def\figurename{\textbf{\c{S}ekil}}
\def\tablename{\textbf{\c{C}izelge}}
This is why I set the 3rd values in \l@figure and \l@table to 3.7em and 5em, respectively.

I have a question now.
Suppose that after compiling my tex, I get the longest prefix together with its counter, how can I learn its lenght?
For instance, my longest prefix for table is "Çizelge 2.1.1", how can I learn its lenght to set the 3rd argument in \l@table in a better way.

Thank you very much.
bkarpuz
Last edited by bkarpuz on Mon Feb 13, 2012 6:45 am, edited 1 time in total.
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Adding Prefixes to LoF and LoT Entries

Post by localghost »

I'm quite sure that there are some solutions by the tocloft package in the forum archive because this has been discussed here quite often (no time to search them at the moment).


Thorsten
Post Reply