GeneralHow to add some elements to the contents

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
luzmara
Posts: 18
Joined: Thu Sep 04, 2008 3:45 pm

How to add some elements to the contents

Post by luzmara »

Hi,

In my contents appears the abstract, my list of figures and tables, then the introduction and my sections. I need to put a point between the name of my section, lits of figures and tables and the page number, I'm working with document class article.

Also I need tha the captions of my tables in the document appear aligned to left.

Its appears like this

abstract 1
list of figures 2
list of tables 3
1. Introduction 4
2. literature 5
2.1. literature century XX ......... 6
.
.
3. conclusions 30


I nedd like this

abstrarct ................................ 1
list of figures .......................... 2
list of tables ........................... 3
1. introduction ........................ 4
2. literature ............................ 5
2.1 literature century XX ......... 6
.
.
.
3. conclusions ........................ 30

Thanks,

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

How to add some elements to the contents

Post by gmedina »

Hi,

you could use one of the packages titletoc ot the tocloft.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
luzmara
Posts: 18
Joined: Thu Sep 04, 2008 3:45 pm

Re: How to add some elements to the contents

Post by luzmara »

Thanks, I tried but I don't find how to make what I need.
If someone else know how to make, please tell me.
User avatar
localghost
Site Moderator
Posts: 9201
Joined: Fri Feb 02, 2007 12:06 pm

How to add some elements to the contents

Post by localghost »

Refer to Section 2.3 (Typesetting the entries, p. 8ff) of the tocloft documentation to modify the leader lines. The caption justification can be done with the caption package.


Best regards
Thorsten¹
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes[/size]

¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

How to add some elements to the contents

Post by gmedina »

Hi luzmara,

the following code ahows that redefining a single command will produce the desired dotted rule for the sections in the ToC. Regarding your captions issue, the standard behaviour is to place the captions aligned to the left. We will need a more precise description of this problem and maybe a minimal working example showing the undesired behaviour.

Code: Select all

\documentclass{article}
\usepackage{tocloft}

\renewcommand{\cftsecdotsep}{\cftdotsep}

\begin{document}

\tableofcontents
\newpage

\section*{Abstract}
\addcontentsline{toc}{section}{Abstract}
\newpage

\listoftables
\addcontentsline{toc}{section}{List of Tables}
\newpage

\listoffigures
\addcontentsline{toc}{section}{List of Figures}
\newpage

\section{Introduction}

\section{Literature}

\subsection{Literature century XX}

\begin{table}[!ht]
  \centering
  \begin{tabular}{cc}\hline
    some text & some text \\\hline
  \end{tabular}
  \caption{text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text}
  \label{tab:test}
\end{table}

\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
luzmara
Posts: 18
Joined: Thu Sep 04, 2008 3:45 pm

How to add some elements to the contents

Post by luzmara »

Hi gmedina,

Thanks again, my first question is now answered, but my problem with the caption still continued, I'm using the ‘hang’ option in the package caption2 to indents the caption text, so it will ‘hang’ under the first line of the text, and when the caption of my table or figure is just a simple line, appears centering, and I need aligned to the left, with the others captions with more than one line there is not problem. The same happend with the figures. I will waiting for your suggestions. The example is

Code: Select all

\documentclass{article}
\usepackage{subfigure}
\usepackage[normal,hang]{caption2} 
\renewcommand{\captionlabeldelim}{ -}
\usepackage[titles,subfigure]{tocloft}

%To introduce the word Table and Figure in the list of tables and list of figures
\renewcommand{\cfttabpresnum}{Table }
\renewcommand{\cftfigpresnum}{Figure }
\renewcommand{\cfttabaftersnum}{ - }
\renewcommand{\cftfigaftersnum}{ - }
\renewcommand{\cfttabnumwidth}{4.7em}
\renewcommand{\cftfignumwidth}{4.7em}
\renewcommand{\cfttabindent}{0em} 
\renewcommand{\cftfigindent}{0em} 

\renewcommand{\cftsecdotsep}{\cftdotsep}

\begin{document}

\tableofcontents
\newpage

\section*{Abstract}
\addcontentsline{toc}{section}{Abstract}
\newpage

\listoftables
\addcontentsline{toc}{section}{List of Tables}
\newpage

\listoffigures
\addcontentsline{toc}{section}{List of Figures}
\newpage

\section{Introduction}

\section{Literature}

\subsection{Literature century XX}

\begin{table}[!ht]
  \caption{text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text}
  \label{tab:test}
  \centering
  \begin{tabular}{cc}\hline
    some text & some text \\\hline
  \end{tabular}
\end{table}

\begin{table}[!ht]
  \caption{text text text text text}
  \label{tab:test1}
  \centering
  \begin{tabular}{cccccc}\hline
    some text & some text & some text & some text & some text & some text \\ \hline
  \end{tabular}
\end{table}

\begin{figure}[!ht]
  \centering
  %\includegraphics[width=15.0cm,height=9.0cm]{BiplotAMMI2Prod.eps}
  \caption{text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text}
   \label{Fig:test}
\end{figure}

\begin{figure}[!ht]
  \centering
  %\includegraphics[width=15.0cm,height=9.0cm]{BiplotAMMI2Prod.eps}
   \caption{text text text text text}
   \label{Fig:test1}
\end{figure}

\end{document}
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

How to add some elements to the contents

Post by gmedina »

Hi luzmara,

caption2 is an obsolete package; you should use caption instead. The following code shows how to achieve what you desire, using the \captionsetup command (refer to the caption package documentation for further information).

Code: Select all

\documentclass{article}
\usepackage{caption}
\captionsetup{format=hang,labelsep=endash,singlelinecheck=false}

\begin{document}


\begin{table}[!ht]
  \caption{text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text}
  \label{tab:test}
  \centering
  \begin{tabular}{cc}\hline
    some text & some text \\\hline
  \end{tabular}
\end{table}

\begin{table}[!ht]
  \caption{text text text text text}
  \label{tab:test1}
  \centering
  \begin{tabular}{cccccc}\hline
    some text & some text & some text & some text & some text & some text \\ \hline
  \end{tabular}
\end{table}

\begin{figure}[!ht]
  \centering
  \caption{text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text}
   \label{Fig:test}
\end{figure}

\begin{figure}[!ht]
  \centering
   \caption{text text text text text}
   \label{Fig:test1}
\end{figure}

\end{document}
By the way, I noticed that you are loading the also obsolete subfigure package. In its stead, you should use subfig or the subcaption package (a little yet useful companion of the caption package).
1,1,2,3,5,8,13,21,34,55,89,144,233,...
luzmara
Posts: 18
Joined: Thu Sep 04, 2008 3:45 pm

Re: How to add some elements to the contents

Post by luzmara »

Hi gmedina, :)

Thanks for the help, its works so good, just a final question, the norms in my university require that the captions of the tables with one line appear aligned to the left, and the captions for the figures with one line appear centering. How can I do this?, the command that you send me modify all the captions of tables and figures.

Thank you so much
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

How to add some elements to the contents

Post by gmedina »

Hi,

replace

Code: Select all

\captionsetup{format=hang,labelsep=endash,singlelinecheck=false}
with

Code: Select all

\captionsetup[figure]{format=hang,labelsep=endash}
\captionsetup[table]{format=hang,labelsep=endash,singlelinecheck=false}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
luzmara
Posts: 18
Joined: Thu Sep 04, 2008 3:45 pm

Re: How to add some elements to the contents

Post by luzmara »

Hi gmedina,

Thank you so much four your help, all my questions were solved.

:D
Post Reply