Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
activematt
Posts: 5 Joined: Sun Mar 27, 2011 9:28 am
Post
by activematt » Sun Mar 27, 2011 9:43 am
I am attempting to add figures to my table of contents using \addcontentsline{toc}{figure} however in the toc they appear left justified. Is there a way to shift the figure right, or a more elegant way of doing this?
Code: Select all
\usepackage[titles,subfigure]{tocloft}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%defines Table of Contents Indents
\renewcommand{\cftsecindent}{0 em}
\renewcommand{\cftsecnumwidth}{2.4 em}
\renewcommand{\cftsubsecindent}{2.4 em}
\renewcommand{\cftsubsecnumwidth}{3.0 em}
\renewcommand{\cftsubsubsecindent}{4.7 em}
\renewcommand{\cftsubsubsecnumwidth}{4.7 em}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newlength\mylength
\settowidth\mylength{figure\hspace*{3em}}
\addtolength\cftfignumwidth{\mylength}
\renewcommand\cftfigpresnum{figure}
\begin{document} % START THE DOCUMENT!
\section{Abstract}
\section{Contents}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\setcounter{tocdepth}{4}
\tableofcontents
\addtocounter{figure}{4}
\newpage
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Introduction}
\section{Methods}
\subsection{\large Apparatus}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{figure}[H]
\centering
\subfloat{\label{fig:1}\includegraphics[width=6in,height=4in]{Apparatus.png}} \\
\caption{Shaky Table Apparatus Schematic\hspace*{3em}}
\end{figure}
\addcontentsline{toc}{figure}{Figure 1:Shaky Table Apparatus Schematic}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\end{document} %
Thanks in advance! Im sorry if my post is too lengthy, this is my first! Open to constructive criticism!
Last edited by
activematt on Sun Mar 27, 2011 10:01 pm, edited 3 times in total.
NEW: TikZ book now 40% off at Amazon.com for a short time.
localghost
Site Moderator
Posts: 9202 Joined: Fri Feb 02, 2007 12:06 pm
Post
by localghost » Sun Mar 27, 2011 9:53 am
I have two questions.
Why don't you just use \listoffigures to get a LoF?
Why do you insert a sub-float in a figure environment with only one image?
activematt wrote: […] Im sorry if my post is too lengthy, this is my first! Open to constructive criticism!
View topic:
Avoidable mistakes
Best regards and welcome to the board
Thorsten
activematt
Posts: 5 Joined: Sun Mar 27, 2011 9:28 am
Post
by activematt » Sun Mar 27, 2011 10:00 am
1) I may just include a toc and lof separately, however my professor requested that the figures be listed in the toc, for faster reference.
2) the report will contain many images
localghost
Site Moderator
Posts: 9202 Joined: Fri Feb 02, 2007 12:06 pm
Post
by localghost » Sun Mar 27, 2011 10:58 am
activematt wrote: 1) I may just include a toc and lof separately, however my professor requested that the figures be listed in the toc, for faster reference. […]
You have to choose one of the given heading levels to get the figure inserted properly into the ToC (see code below).
activematt wrote: 2) the report will contain many images
That's not the point. You don't need to declare a sub-float inside a float if there is only one object (see code below).
Code: Select all
\documentclass[11pt,a4paper,english]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage[includeheadfoot,margin=2cm]{geometry}
\usepackage[titles]{tocloft}
\usepackage{blindtext}
% define ToC indents
\renewcommand{\cftsecindent}{0em}
\renewcommand{\cftsecnumwidth}{2.4em}
\renewcommand{\cftsubsecindent}{2.4em}
\renewcommand{\cftsubsecnumwidth}{3.0em}
\renewcommand{\cftsubsubsecindent}{4.7em}
\renewcommand{\cftsubsubsecnumwidth}{4.7em}
%\newlength\mylength
%\settowidth\mylength{Figure\hspace*{3em}}
%\addtolength\cftfignumwidth{\mylength}
%\renewcommand\cftfigpresnum{Figure}
\begin{document}
\tableofcontents
\blinddocument
\begin{figure}[!ht]
\centering
\rule{0.75\textwidth}{0.5\textwidth}
\caption{Dummy figure}\label{fig:dummy}
\addcontentsline{toc}{subsubsection}{\figurename\ \ref{fig:dummy}: Dummy figure}
\end{figure}
\end{document}
activematt
Posts: 5 Joined: Sun Mar 27, 2011 9:28 am
Post
by activematt » Sun Mar 27, 2011 10:02 pm
This Seems To Work Well!
Code: Select all
\documentclass[11pt,a4paper,english]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage[includeheadfoot,margin=2cm]{geometry}
\usepackage[titles]{tocloft}
%\usepackage{blindtext}
\usepackage{graphicx} % For images
% define ToC indents
\renewcommand{\cftsecindent}{0em}
\renewcommand{\cftsecnumwidth}{2.4em}
\renewcommand{\cftsubsecindent}{2.4em}
\renewcommand{\cftsubsecnumwidth}{3.0em}
\renewcommand{\cftsubsubsecindent}{4.7em}
\renewcommand{\cftsubsubsecnumwidth}{4.7em}
\begin{document}
\tableofcontents
\section{Intro}
%\blinddocument
\subsection{Equipment}
\begin{figure}[!ht]
\centering
\includegraphics[width=6in,height=4in]{Apparatus.png}
\caption{Apparatus}\label{fig:Apparatus}
\addcontentsline{toc}{subsubsection}{\figurename\ \ref{fig:Apparatus}: Shaky Table Apparatus}
\end{figure}
\end{document}
Thx for all the help!