Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am new here, but not new to LaTeX.

My question concerns the topic discussed in this thread: Pretty Table of Contents.

The topic is about how to make a pretty Table of Contens. My question is now, what do I need to do in order to apply the same pretty layout style of the TOC on the LOF and LOT?

How can I override the pretty TOC layout on LOF and LOT?


For your information:

  • I have copied my minimal working example from Gonzalo Medina in the linked post and modified it a little bit.
  • I use the memoir class for my minimal working example.
  • I have added a Part TOC (just to see if it looks good etc.). However, in my opinion a Part TOC is only good-looking if it can stay on the same page as the part text. Otherwise, it does not look good, and then one has to consider to put the Part TOC on the following page. By the way, I do not remember if someone in the community already did post something about making a Part TOC. In this case: Here you are! :-)
  • My minimal working example uses different colours in the TOC and Part TOC (same colours in both TOCs of course) to make it easier to see what the different code blocks do in the preamble under the Pretty TOC code section.
  • Be careful when using the hyperref package with the \hypersetup command! If colorlinks is set to true, then the (red) colour in the chapter text in the TOC disappears.
  • Also, be aware about the fact that you then need to colour your URLs manually if you want your URLs to be something else than black when using the \url{} command!

    • [SOLUTION] regarding the URLs is to apply the \renewcommand{\UrlFont}{\color{cyan}} (or the colour you would like...) AFTER the \hypersetup code block in the preamble! If doing so, this will solve the 'lack of URL colour' problem, allowing to use the \url command as you are used to.

And here is my minimal working example:

\documentclass[a4paper,11pt,twoside,openright]{memoir}
\usepackage{fixltx2e}

\usepackage[english]{babel}

\usepackage[T1]{fontenc}
\usepackage{ae,aecompl}
\usepackage[utf8]{inputenx}

\usepackage{float}
\usepackage{graphicx}

\setlrmargins{*}{*}{1}
\setulmargins{*}{*}{1}
\checkandfixthelayout[nearest]

\usepackage{color}
\usepackage{xcolor}

\usepackage{mdframed}   
\usepackage{mathtools}
\usepackage{hyphenat}       % I use it to prevent hyphenation of table of contents items
\usepackage{refcount}
\usepackage{tikz}
\usetikzlibrary{calc}
%%% Do not include titletoc here - do it at the end of the "Pretty TOC" (very important!)
% WHY? Because then in the Part TOC, the next part will be displayed in the very end of that Part TOC! Of course, this will not happen in the very last Part TOC because there is no part after that...
% \usepackage{titletoc}             


%%% Pretty TOC
%%%%% adapted from http://tex.stackexchange.com/questions/35825/pretty-table-of-contents/35835
% a modification of the leftbar environment defined by the framed package
% will be used to place a vertical colored bar separating the page number and the
% title in chapter entries
\renewenvironment{leftbar}{%
  \def\FrameCommand{\textcolor{green}{\vrule width 1.5pt depth 0pt}\hspace*{15pt}}%
  \MakeFramed{\advance\hsize-\width\FrameRestore}}%
 {\endMakeFramed}

\makeatletter

% a command to circle the part numbers
\newcommand\Circle[1]{\tikz[overlay,remember picture] 
  \node[draw=blue,circle, text width=18pt,line width=1pt,align=center] {#1};}

% redefinitions for part entries
\renewcommand\cftpartfont{\Large\sffamily\bfseries}
\renewcommand\partnumberline[1]{%
    \hbox to \textwidth{\hss\Circle{\textcolor{red}{#1}}\hss}%
  \vskip 3.5ex\color{cyan}}

\renewcommand*{\l@part}[2]{%
  \ifnum \c@tocdepth >-2\relax
    \cftpartbreak
    \begingroup
      {\interlinepenalty\@M
       \leavevmode
       \settowidth{\@tempdima}{\cftpartfont\cftpartname}%
       \addtolength{\@tempdima}{\cftpartnumwidth}%
       \let\@cftbsnum \cftpartpresnum
       \let\@cftasnum \cftpartaftersnum
       \let\@cftasnumb \cftpartaftersnumb
       \advance\memRTLleftskip\@tempdima \null\nobreak\hskip -\memRTLleftskip
       \centering{\cftpartfont#1}\par%
       }
      \nobreak
        \global\@nobreaktrue
        \everypar{\global\@nobreakfalse\everypar{}}%
    \endgroup
  \fi}


% redefinitions for chapter entries
\renewcommand\chapternumberline[1]{\mbox{\small\@chapapp~#1}\par\noindent\Large}
\renewcommand\cftchapterfont{\sffamily}
\cftsetindents{chapter}{0pt}{0em}
\renewcommand\cftchapterpagefont{\large\sffamily\bfseries\color{blue}}

\newcommand*{\l@mychap}[3]{%
  \def\@chapapp{\large\color{cyan}#3}
  \vskip1ex%
  \par\noindent\begin{minipage}{\textwidth}%
  \parbox{4.5em}{%
    \hfill{\cftchapterpagefont#2}%
  }\hspace*{1.5em}%
  \parbox{\dimexpr\textwidth-4.5em-15pt\relax}{%
    \leftbar\cftchapterfont{\color{red}#1}\hspace{1sp}\endleftbar%
  }%
  \end{minipage}\par%
}
\renewcommand*{\l@chapter}[2]{%
  \l@mychap{#1}{#2}{\chaptername}%
}
\renewcommand*{\l@appendix}[2]{%
  \l@mychap{#1}{#2}{\appendixname}%
}

% redefinitions for section entries
\renewcommand\cftsectionfont{\sffamily\color{black}}
\renewcommand\cftsectionpagefont{\sffamily\itshape\color{blue}}
\renewcommand\cftsectionleader{\nobreak}
\renewcommand\cftsectiondotsep{\cftnodots}
\renewcommand\cftsectionafterpnum{\hspace*{\fill}}
\setlength\cftsectionnumwidth{12em}
\cftsetindents{section}{6em}{3em}
\renewcommand\cftsectionformatpnum[1]{%
  \hskip1em\hbox to \@pnumwidth{{\cftsectionpagefont #1\hfill}}}

% redefinitions for subsection entries
\renewcommand\cftsubsectionfont{\sffamily\color{black}}
\renewcommand\cftsubsectionpagefont{\sffamily\itshape\color{blue}}
\renewcommand\cftsubsectionleader{\nobreak}
\renewcommand\cftsubsectiondotsep{\cftnodots}
\renewcommand\cftsubsectionafterpnum{\hspace*{\fill}}
\setlength\cftsubsectionnumwidth{12em}
\cftsetindents{subsection}{9em}{3em}
\renewcommand\cftsubsectionformatpnum[1]{%
  \hskip1em\hbox to \@pnumwidth{{\cftsubsectionpagefont #1\hfill}}}
\makeatother

%%%% End of Pretty ToC

\settocdepth{subsection}
\setsecnumdepth{subsection}

% include after the change above (very important!)
\usepackage{titletoc}

\makeatletter
\def\@endpart{
%
  \vfil
  \textcolor{red}{\hrule height 1.5 pt}
\setcounter{tocdepth}{0}

    \startcontents[parts]
    \printcontents[parts]{}{0}{}

\textcolor{red}{\hrule height 1.5 pt}
  \par\bigskip
  \vfil\newpage
              \if@twoside
               \if@openright
                \null
                \thispagestyle{empty}%
                \newpage
               \fi
              \fi
              \if@tempswa
                \twocolumn
              \fi}
\makeatother
%%%

% be careful with the hyperref package; if colorlinks = true, then the (red) color in the chapter text in the TOC and  disappears! 
\usepackage{varioref,hyperref}
\hypersetup{
    bookmarks=true,                 % show bookmarks bar?
    unicode=false,                  % non-Latin characters in Acrobat’s bookmarks
    pdftoolbar=true,                % show Acrobat’s toolbar?
    pdfmenubar=true,                % show Acrobat’s menu?
    pdffitwindow=true ,             % window fit to page when opened
    pdfstartview={FitH},            % fits the width of the page to the window
    pdftitle={},                    % title
    pdfauthor={},   % author
    pdfsubject={},      % subject of the document
    pdfnewwindow=true,              % links in new window
    colorlinks=false,                   % false: boxed links; true: colored links
    linkcolor=black,                % color of internal links (change box color with linkbordercolor)
    citecolor=black,                % color of links to bibliography
    filecolor=black,                % color of file links
    %urlcolor=cyan              % color of external links
}

\renewcommand{\UrlFont}{\color{cyan}}   % must come after \hypersetup code block!

\begin{document}

\frontmatter

    \tableofcontents*
    \cleardoublepage
    \listoffigures
    \cleardoublepage
    \listoftables
    \cleardoublepage

\chapter{Foreword}
Be careful about the URLs. Because the colorlinks is set to false (in the hypersetup in the preamble), this is how the URL will look like: \newline

\url{http://tex.stackexchange.com/questions/169068} \newline

\noindent
If you would like to have the URLs in a specific colour, you have to manually colour code them: \newline

{\color{cyan}{\url{http://tex.stackexchange.com/questions/169068}}} \newline

\noindent
However, If you do not care about the chapter text colour in the TOC (if you want it black, which is standard), then the colorlinks can be set to true, which then should colour code the URLs automatically.


\mainmatter

\part{Designing with \TeX\ and \LaTeX}

\begin{figure}[H]
    \caption[(short) caption that goes to the LOF.]{(long) caption that goes below the figure}
\end{figure}

\begin{figure}[H]
    \caption[(short) caption that goes to the LOF.]{(long) caption that goes below the figure}
\end{figure}

\begin{figure}[H]
    \caption[(short) caption that goes to the LOF.]{(long) caption that goes below the figure}
\end{figure}

\begin{figure}[H]
    \caption[(short) caption that goes to the LOF.]{(long) caption that goes below the figure}
\end{figure}

\begin{figure}[H]
    \caption[(short) caption that goes to the LOF.]{(long) caption that goes below the figure}
\end{figure}

\chapter{Beginning to learn design with \TeX}
\section{Another test section}
\section{Another test section}

\begin{table}[H]
    \caption[(short) caption that goes to the LOT.]{(long) caption that goes below the figure}
\end{table}

\begin{table}[H]
    \caption[(short) caption that goes to the LOT.]{(long) caption that goes below the figure}
\end{table}

\begin{table}[H]
    \caption[(short) caption that goes to the LOT.]{(long) caption that goes below the figure}
\end{table}

\subsection{A test subsection}
\section{Another test section}
\subsection{A test subsection}
\subsection{A test subsection with a long title spanning more than one line in the table of contents}
\section{Another test section}
\section{Another test section}
\section{Another test section}



\chapter{Beginning to learn design with \LaTeX}
\section{A test section with a long title spanning more than one line in the table of contents}
\subsection{A test subsection}
\subsection{Another test subsection}
\section{A test section}
\phantomsection
\addcontentsline{toc}{section}{Test unnumbered section}
\section*{Test unnumbered section}
\subsection{A test subsection}
\section{Another test section}
\subsection{A test subsection}
\subsection{A test subsection}
\section{Another test section}
\section{Another test section}


\newpage\setcounter{page}{123}% just for the example

\part{Designing with HTML}

\chapter{Beginning to learn design with HTML and some other text to span more than one line}

\begin{figure}[H]
    \caption[(short) caption that goes to the LOF.]{(long) caption that goes below the figure}
\end{figure}

\begin{figure}[H]
    \caption[(short) caption that goes to the LOF.]{(long) caption that goes below the figure}
\end{figure}

\begin{figure}[H]
    \caption[(short) caption that goes to the LOF.]{(long) caption that goes below the figure}
\end{figure}

\section{Another test section}

\begin{table}[H]
    \caption[(short) caption that goes to the LOT.]{(long) caption that goes below the figure}
\end{table}

\begin{table}[H]
    \caption[(short) caption that goes to the LOT.]{(long) caption that goes below the figure}
\end{table}

\begin{table}[H]
    \caption[(short) caption that goes to the LOT.]{(long) caption that goes below the figure}
\end{table}

\section{Another test section}
\subsection{A test subsection}
\section{Another test section with a long title spanning more than one line in the table of contents}
\subsection{A test subsection}
\section{Another test section}



\chapter{Beginning to learn design with HTML and some other text to span more than one line} 
\section{Another test section}
\section{Another test section}
\subsection{A test subsection}
\subsection{A test subsection with a long title spanning more than one line in the table of contents}
\section{Another test section}
\section{Another test section}
\subsection{A test subsection}



\appendix

\chapter{Test Appendix}
\section{Another test section}

\begin{figure}[H]
    \caption[(short) caption that goes to the LOF.]{(long) caption that goes below the figure}
\end{figure}

\begin{figure}[H]
    \caption[(short) caption that goes to the LOF.]{(long) caption that goes below the figure}
\end{figure}

\begin{figure}[H]
    \caption[(short) caption that goes to the LOF.]{(long) caption that goes below the figure}
\end{figure}

\section{Another test section with a long title spanning more than one line in the table of contents}
\section{Another test section}

\begin{table}[H]
    \caption[(short) caption that goes to the LOT.]{(long) caption that goes below the figure}
\end{table}

\begin{table}[H]
    \caption[(short) caption that goes to the LOT.]{(long) caption that goes below the figure}
\end{table}

\begin{table}[H]
    \caption[(short) caption that goes to the LOT.]{(long) caption that goes below the figure}
\end{table}

\subsection{A test subsection}
\section{Another test section}
\section{Another test section}

\end{document}

And this is how some of it looks like:


TOC


TOC


LOF


LOT


How the URLs get affected


Part TOC


Part TOC


share|improve this question
    
Which of the various options presented in the linked answer would you like to have? –  Gonzalo Medina Apr 2 at 12:57
    
I have just updated my question :-) –  poltexious Apr 3 at 23:37
    
Thanks for the update! However, you forgot to include some important information: how do you want the entries in the LOF and LoT to look like? What's the desired output for the lists? –  Gonzalo Medina Apr 4 at 0:36
    
I was thinking about the same layout in the LOF and LOT as is presented in the TOC. That is, no dots between the text and the page number. Furthermore, the same distance between the text and the page number on which the float is displayed - just like in the TOC (with the same colour and font style as well). –  poltexious Apr 4 at 0:56
    
I see. Please see my answer below. Is it something like that what you want to achieve? –  Gonzalo Medina Apr 4 at 1:41

3 Answers 3

up vote 6 down vote accepted

I had to provide a different answer since when I tried to edit my previous answer to include the new code, the 30.000 character limit was exceeded.

A little modification suggested in a comment: some information for chapters is automatically included in the LoF (LoT, resp.) only for those chapters containing figures (tables, resp.).

\documentclass[a4paper,11pt,twoside,openright]{memoir}
\usepackage{fixltx2e}

\usepackage[english]{babel}

\usepackage[T1]{fontenc}
\usepackage{ae,aecompl}
\usepackage[utf8]{inputenx}

\usepackage{float}
\usepackage{graphicx}

\setlrmargins{*}{*}{1}
\setulmargins{*}{*}{1}
\checkandfixthelayout[nearest]

\usepackage{color}
\usepackage{xcolor}

\usepackage{mdframed}   
\usepackage{mathtools}
\usepackage{hyphenat}       % I use it to prevent hyphenation of table of contents items
\usepackage{refcount}
\usepackage{tikz}
\usetikzlibrary{calc}
%%% Do not include titletoc here - do it at the end of the "Pretty TOC" (very important!)
% WHY? Because then in the Part TOC, the next part will be displayed in the very end of that Part TOC! Of course, this will not happen in the very last Part TOC because there is no part after that...
% \usepackage{titletoc}             


%%% Pretty TOC
%%%%% adapted from http://tex.stackexchange.com/questions/35825/pretty-table-of-contents/35835
% a modification of the leftbar environment defined by the framed package
% will be used to place a vertical colored bar separating the page number and the
% title in chapter entries
\renewenvironment{leftbar}{%
  \def\FrameCommand{\textcolor{green}{\vrule width 1.5pt depth 0pt}\hspace*{15pt}}%
  \MakeFramed{\advance\hsize-\width\FrameRestore}}%
 {\endMakeFramed}

\makeatletter


% a command to circle the part numbers
\newcommand\Circle[1]{\tikz[overlay,remember picture] 
  \node[draw=blue,circle, text width=18pt,line width=1pt,align=center] {#1};}

% redefinitions for part entries
\renewcommand\cftpartfont{\Large\sffamily\bfseries}
\renewcommand\partnumberline[1]{%
    \hbox to \textwidth{\hss\Circle{\textcolor{red}{#1}}\hss}%
  \vskip 3.5ex\color{cyan}}

\renewcommand*{\l@part}[2]{%
  \ifnum \c@tocdepth >-2\relax
    \cftpartbreak
    \begingroup
      {\interlinepenalty\@M
       \leavevmode
       \settowidth{\@tempdima}{\cftpartfont\cftpartname}%
       \addtolength{\@tempdima}{\cftpartnumwidth}%
       \let\@cftbsnum \cftpartpresnum
       \let\@cftasnum \cftpartaftersnum
       \let\@cftasnumb \cftpartaftersnumb
       \advance\memRTLleftskip\@tempdima \null\nobreak\hskip -\memRTLleftskip
       \centering{\cftpartfont#1}\par%
       }
      \nobreak
        \global\@nobreaktrue
        \everypar{\global\@nobreakfalse\everypar{}}%
    \endgroup
  \fi}


% redefinitions for chapter entries
\renewcommand\chapternumberline[1]{\mbox{\small\@chapapp~#1}\par\noindent\Large}
\renewcommand\cftchapterfont{\sffamily}
\cftsetindents{chapter}{0pt}{0em}
\renewcommand\cftchapterpagefont{\large\sffamily\bfseries\color{blue}}

\newcommand*{\l@mychap}[3]{%
  \def\@chapapp{\large\color{cyan}#3}
  \vskip1ex%
  \par\noindent\begin{minipage}{\textwidth}%
  \parbox{4.5em}{%
    \hfill{\cftchapterpagefont#2}%
  }\hspace*{1.5em}%
  \parbox{\dimexpr\textwidth-4.5em-15pt\relax}{%
    \leftbar\cftchapterfont{\color{red}#1}\hspace{1sp}\endleftbar%
  }%
  \end{minipage}\par%
}
\renewcommand*{\l@chapter}[2]{%
  \l@mychap{#1}{#2}{\chaptername}%
}
\renewcommand*{\l@appendix}[2]{%
  \l@mychap{#1}{#2}{\appendixname}%
}

% redefinitions for section entries
\renewcommand\cftsectionfont{\sffamily\color{black}}
\renewcommand\cftsectionpagefont{\sffamily\itshape\color{blue}}
\renewcommand\cftsectionleader{\nobreak}
\renewcommand\cftsectiondotsep{\cftnodots}
\renewcommand\cftsectionafterpnum{\hspace*{\fill}}
\setlength\cftsectionnumwidth{12em}
\cftsetindents{section}{6em}{3em}
\renewcommand\cftsectionformatpnum[1]{%
  \hskip1em\hbox to \@pnumwidth{{\cftsectionpagefont #1\hfill}}}

% redefinitions for subsection entries
\renewcommand\cftsubsectionfont{\sffamily\color{black}}
\renewcommand\cftsubsectionpagefont{\sffamily\itshape\color{blue}}
\renewcommand\cftsubsectionleader{\nobreak}
\renewcommand\cftsubsectiondotsep{\cftnodots}
\renewcommand\cftsubsectionafterpnum{\hspace*{\fill}}
\setlength\cftsubsectionnumwidth{12em}
\cftsetindents{subsection}{9em}{3em}
\renewcommand\cftsubsectionformatpnum[1]{%
  \hskip1em\hbox to \@pnumwidth{{\cftsubsectionpagefont #1\hfill}}}

%%%% End of Pretty ToC

\settocdepth{subsection}
\setsecnumdepth{subsection}

% redefinitions for figure entries
\renewcommand\cftfigurefont{\sffamily\color{black}}
\renewcommand\cftfigurepagefont{\sffamily\itshape\color{blue}}
\renewcommand\cftfigureleader{\nobreak}
\renewcommand\cftfiguredotsep{\cftnodots}
\renewcommand\cftfigureafterpnum{\hspace*{\fill}}
\setlength\cftfigurenumwidth{12em}
\cftsetindents{figure}{6em}{3em}
\renewcommand\cftfigureformatpnum[1]{%
  \hskip1em\hbox to \@pnumwidth{{\cftfigurepagefont #1\hfill}}}

% redefinitions for table entries
\renewcommand\cfttablefont{\sffamily\color{black}}
\renewcommand\cfttablepagefont{\sffamily\itshape\color{blue}}
\renewcommand\cfttableleader{\nobreak}
\renewcommand\cfttabledotsep{\cftnodots}
\renewcommand\cfttableafterpnum{\hspace*{\fill}}
\setlength\cfttablenumwidth{12em}
\cftsetindents{table}{6em}{3em}
\renewcommand\cfttableformatpnum[1]{%
  \hskip1em\hbox to \@pnumwidth{{\cfttablepagefont #1\hfill}}}

\usepackage{etoolbox}  % or xpatch

% the following code adds chapter information into the LoF 
% for chapters containing figures
% initial definitions of the chapter info (name and number)
\def\thischaptertitle{}\def\thischapternumber{}
\newtoggle{noFigs}

\apptocmd{\@chapter}%
  {\gdef\thischaptertitle{#2}\gdef\thischapternumber{\thechapter}%
    \global\toggletrue{noFigs}}{}{}

% the figure environment does the job: the first time it is used after a \chapter command, 
% it writes the information of the chapter to the LoF
\AtBeginDocument{%
  \AtBeginEnvironment{figure}{%
    \iftoggle{noFigs}{
      \addtocontents{lof}{\protect\contentsline {chapter}%
        {\protect\numberline {\large\color{cyan}\@chapapp~\thischapternumber}{\thischaptertitle}}{}{} }
      \global\togglefalse{noFigs}
    }{}
  }%
}

% the following code adds chapter information into the LoT 
% for chapters containing tables
\newtoggle{noTabs}

\apptocmd{\@chapter}%
  {\gdef\thischaptertitle{#2}\gdef\thischapternumber{\thechapter}%
    \global\toggletrue{noTabs}}{}{}

% the table environment does the job: the first time it is used after a \chapter command, 
% it writes the information of the chapter to the LoT
\AtBeginDocument{%
  \AtBeginEnvironment{table}{%
    \iftoggle{noTabs}{
      \addtocontents{lot}{\protect\contentsline {chapter}%
        {\protect\numberline {\large\color{cyan}\@chapapp~\thischapternumber}{\thischaptertitle}}{}{} }
      \global\togglefalse{noTabs}
    }{}
  }%
}

% include after the change above (very important!)
\usepackage{titletoc}

\def\@endpart{
%
  \vfil
  \textcolor{red}{\hrule height 1.5 pt}
\setcounter{tocdepth}{0}

    \startcontents[parts]
    \printcontents[parts]{}{0}{} % change 0 to 1 etc. for more detail and vice versa

\textcolor{red}{\hrule height 1.5 pt}
  \par\bigskip
  \vfil\newpage
              \if@twoside
               \if@openright
                \null
                \thispagestyle{empty}%
                \newpage
               \fi
              \fi
              \if@tempswa
                \twocolumn
              \fi}
\makeatother
%%%

% be careful with the hyperref package; if colorlinks = true, then the (red) color in the chapter text in the TOC and  disappears! 
\usepackage{varioref,hyperref}
\hypersetup{
    bookmarks=true,                 % show bookmarks bar?
    unicode=false,                  % non-Latin characters in Acrobat’s bookmarks
    pdftoolbar=true,                % show Acrobat’s toolbar?
    pdfmenubar=true,                % show Acrobat’s menu?
    pdffitwindow=true ,             % window fit to page when opened
    pdfstartview={FitH},            % fits the width of the page to the window
    pdftitle={},                    % title
    pdfauthor={},   % author
    pdfsubject={},      % subject of the document
    pdfnewwindow=true,              % links in new window
    hidelinks=true,
    colorlinks=false,                   % false: boxed links; true: colored links
    linkcolor=black,                % color of internal links (change box color with linkbordercolor)
    citecolor=black,                % color of links to bibliography
    filecolor=black,                % color of file links
    urlcolor=aau-purple             % color of external links
}

\begin{document}

\frontmatter

    \tableofcontents*
    \cleardoublepage
    \listoffigures
    \cleardoublepage
    \listoftables
    \cleardoublepage

\chapter{Foreword}
Be careful about the URLs. Because the colorlinks is set to false (in the hypersetup in the preamble), this is how the URL will look like: \newline

\url{http://tex.stackexchange.com/posts/169068/edit} \newline

\noindent
If you would like to have the URLs in a specific colour, you have to manually colour code them: \newline

{\color{cyan}{\url{http://tex.stackexchange.com/posts/169068/edit}}} \newline

\noindent
However, If you do not care about the chapter  text colour in the TOC (if you want it black, which is standard), then the colorlinks can be set to true, which then should colour code the URLs automatically.


\mainmatter

\part{Designing with \TeX\ and \LaTeX}

\chapter{A test chapter}

\begin{figure}[H]
    \caption[(short) caption that goes to the LOF.]{(long) caption that goes below the figure}
\end{figure}

\begin{figure}[H]
    \caption[(short) caption that goes to the LOF.]{(long) caption that goes below the figure}
\end{figure}

\begin{figure}[H]
    \caption[(short) caption that goes to the LOF.]{(long) caption that goes below the figure}
\end{figure}

\begin{figure}[H]
    \caption[(short) caption that goes to the LOF.]{(long) caption that goes below the figure}
\end{figure}

\begin{figure}[H]
    \caption[(short) caption that goes to the LOF.]{(long) caption that goes below the figure}
\end{figure}

\chapter{Beginning to learn design with \TeX}
\section{Another test section}
\section{Another test section}

\begin{table}[H]
    \caption[(short) caption that goes to the LOT.]{(long) caption that goes below the figure}
\end{table}

\begin{table}[H]
    \caption[(short) caption that goes to the LOT.]{(long) caption that goes below the figure}
\end{table}

\begin{table}[H]
    \caption[(short) caption that goes to the LOT.]{(long) caption that goes below the figure}
\end{table}

\subsection{A test subsection}
\section{Another test section}
\subsection{A test subsection}
\subsection{A test subsection with a long title spanning more than one line in the table of contents}
\section{Another test section}
\section{Another test section}
\section{Another test section}



\chapter{Beginning to learn design with \LaTeX}
\section{A test section with a long title spanning more than one line in the table of contents}
\subsection{A test subsection}
\subsection{Another test subsection}
\section{A test section}
\phantomsection
\addcontentsline{toc}{section}{Test unnumbered section}
\section*{Test unnumbered section}
\subsection{A test subsection}
\section{Another test section}
\subsection{A test subsection}
\subsection{A test subsection}
\section{Another test section}
\section{Another test section}


\newpage\setcounter{page}{123}% just for the example

\part{Designing with HTML}

\chapter{Beginning to learn design with HTML and some other text to span more than one line}

\begin{figure}[H]
    \caption[(short) caption that goes to the LOF.]{(long) caption that goes below the figure}
\end{figure}

\begin{figure}[H]
    \caption[(short) caption that goes to the LOF.]{(long) caption that goes below the figure}
\end{figure}

\begin{figure}[H]
    \caption[(short) caption that goes to the LOF.]{(long) caption that goes below the figure}
\end{figure}

\section{Another test section}

\begin{table}[H]
    \caption[(short) caption that goes to the LOT.]{(long) caption that goes below the figure}
\end{table}

\begin{table}[H]
    \caption[(short) caption that goes to the LOT.]{(long) caption that goes below the figure}
\end{table}

\begin{table}[H]
    \caption[(short) caption that goes to the LOT.]{(long) caption that goes below the figure}
\end{table}

\section{Another test section}
\subsection{A test subsection}
\section{Another test section with a long title spanning more than one line in the table of contents}
\subsection{A test subsection}
\section{Another test section}



\chapter{Beginning to learn design with HTML and some other text to span more than one line} 
\section{Another test section}
\section{Another test section}
\subsection{A test subsection}
\subsection{A test subsection with a long title spanning more than one line in the table of contents}
\section{Another test section}
\section{Another test section}
\subsection{A test subsection}



\appendix

\chapter{Test Appendix}
\section{Another test section}

\begin{figure}[H]
    \caption[(short) caption that goes to the LOF.]{(long) caption that goes below the figure}
\end{figure}

\begin{figure}[H]
    \caption[(short) caption that goes to the LOF.]{(long) caption that goes below the figure}
\end{figure}

\begin{figure}[H]
    \caption[(short) caption that goes to the LOF.]{(long) caption that goes below the figure}
\end{figure}

\section{Another test section with a long title spanning more than one line in the table of contents}
\section{Another test section}

\begin{table}[H]
    \caption[(short) caption that goes to the LOT.]{(long) caption that goes below the figure}
\end{table}

\begin{table}[H]
    \caption[(short) caption that goes to the LOT.]{(long) caption that goes below the figure}
\end{table}

\begin{table}[H]
    \caption[(short) caption that goes to the LOT.]{(long) caption that goes below the figure}
\end{table}

\subsection{A test subsection}
\section{Another test section}
\section{Another test section}

\end{document}

An image of the new resulting LoF:

enter image description here

An image of the new resulting LoT:

enter image description here

share|improve this answer

One option; I used the settings for section entries to format figure and table entries (the only change is that instead of 6em I used 4em for the indent of figure and table entries):

\documentclass[a4paper,11pt,twoside,openright]{memoir}
\usepackage{fixltx2e}

\usepackage[english]{babel}

\usepackage[T1]{fontenc}
\usepackage{ae,aecompl}
\usepackage[utf8]{inputenx}

\usepackage{float}
\usepackage{graphicx}

\setlrmargins{*}{*}{1}
\setulmargins{*}{*}{1}
\checkandfixthelayout[nearest]

\usepackage{color}
\usepackage{xcolor}

\usepackage{mdframed}   
\usepackage{mathtools}
\usepackage{hyphenat}       % I use it to prevent hyphenation of table of contents items
\usepackage{refcount}
\usepackage{tikz}
\usetikzlibrary{calc}
%%% Do not include titletoc here - do it at the end of the "Pretty TOC" (very important!)
% WHY? Because then in the Part TOC, the next part will be displayed in the very end of that Part TOC! Of course, this will not happen in the very last Part TOC because there is no part after that...
% \usepackage{titletoc}             


%%% Pretty TOC
%%%%% adapted from http://tex.stackexchange.com/questions/35825/pretty-table-of-contents/35835
% a modification of the leftbar environment defined by the framed package
% will be used to place a vertical colored bar separating the page number and the
% title in chapter entries
\renewenvironment{leftbar}{%
  \def\FrameCommand{\textcolor{green}{\vrule width 1.5pt depth 0pt}\hspace*{15pt}}%
  \MakeFramed{\advance\hsize-\width\FrameRestore}}%
 {\endMakeFramed}

\makeatletter

% a command to circle the part numbers
\newcommand\Circle[1]{\tikz[overlay,remember picture] 
  \node[draw=blue,circle, text width=18pt,line width=1pt,align=center] {#1};}

% redefinitions for part entries
\renewcommand\cftpartfont{\Large\sffamily\bfseries}
\renewcommand\partnumberline[1]{%
    \hbox to \textwidth{\hss\Circle{\textcolor{red}{#1}}\hss}%
  \vskip 3.5ex\color{cyan}}

\renewcommand*{\l@part}[2]{%
  \ifnum \c@tocdepth >-2\relax
    \cftpartbreak
    \begingroup
      {\interlinepenalty\@M
       \leavevmode
       \settowidth{\@tempdima}{\cftpartfont\cftpartname}%
       \addtolength{\@tempdima}{\cftpartnumwidth}%
       \let\@cftbsnum \cftpartpresnum
       \let\@cftasnum \cftpartaftersnum
       \let\@cftasnumb \cftpartaftersnumb
       \advance\memRTLleftskip\@tempdima \null\nobreak\hskip -\memRTLleftskip
       \centering{\cftpartfont#1}\par%
       }
      \nobreak
        \global\@nobreaktrue
        \everypar{\global\@nobreakfalse\everypar{}}%
    \endgroup
  \fi}


% redefinitions for chapter entries
\renewcommand\chapternumberline[1]{\mbox{\small\@chapapp~#1}\par\noindent\Large}
\renewcommand\cftchapterfont{\sffamily}
\cftsetindents{chapter}{0pt}{0em}
\renewcommand\cftchapterpagefont{\large\sffamily\bfseries\color{blue}}

\newcommand*{\l@mychap}[3]{%
  \def\@chapapp{\large\color{cyan}#3}
  \vskip1ex%
  \par\noindent\begin{minipage}{\textwidth}%
  \parbox{4.5em}{%
    \hfill{\cftchapterpagefont#2}%
  }\hspace*{1.5em}%
  \parbox{\dimexpr\textwidth-4.5em-15pt\relax}{%
    \leftbar\cftchapterfont{\color{red}#1}\hspace{1sp}\endleftbar%
  }%
  \end{minipage}\par%
}
\renewcommand*{\l@chapter}[2]{%
  \l@mychap{#1}{#2}{\chaptername}%
}
\renewcommand*{\l@appendix}[2]{%
  \l@mychap{#1}{#2}{\appendixname}%
}

% redefinitions for section entries
\renewcommand\cftsectionfont{\sffamily\color{black}}
\renewcommand\cftsectionpagefont{\sffamily\itshape\color{blue}}
\renewcommand\cftsectionleader{\nobreak}
\renewcommand\cftsectiondotsep{\cftnodots}
\renewcommand\cftsectionafterpnum{\hspace*{\fill}}
\setlength\cftsectionnumwidth{12em}
\cftsetindents{section}{6em}{3em}
\renewcommand\cftsectionformatpnum[1]{%
  \hskip1em\hbox to \@pnumwidth{{\cftsectionpagefont #1\hfill}}}

% redefinitions for subsection entries
\renewcommand\cftsubsectionfont{\sffamily\color{black}}
\renewcommand\cftsubsectionpagefont{\sffamily\itshape\color{blue}}
\renewcommand\cftsubsectionleader{\nobreak}
\renewcommand\cftsubsectiondotsep{\cftnodots}
\renewcommand\cftsubsectionafterpnum{\hspace*{\fill}}
\setlength\cftsubsectionnumwidth{12em}
\cftsetindents{subsection}{9em}{3em}
\renewcommand\cftsubsectionformatpnum[1]{%
  \hskip1em\hbox to \@pnumwidth{{\cftsubsectionpagefont #1\hfill}}}

%%%% End of Pretty ToC

\settocdepth{subsection}
\setsecnumdepth{subsection}

% redefinitions for figure entries
\renewcommand\cftfigurefont{\sffamily\color{black}}
\renewcommand\cftfigurepagefont{\sffamily\itshape\color{blue}}
\renewcommand\cftfigureleader{\nobreak}
\renewcommand\cftfiguredotsep{\cftnodots}
\renewcommand\cftfigureafterpnum{\hspace*{\fill}}
\setlength\cftfigurenumwidth{12em}
\cftsetindents{figure}{4em}{3em}
\renewcommand\cftfigureformatpnum[1]{%
  \hskip1em\hbox to \@pnumwidth{{\cftfigurepagefont #1\hfill}}}

% redefinitions for table entries
\renewcommand\cfttablefont{\sffamily\color{black}}
\renewcommand\cfttablepagefont{\sffamily\itshape\color{blue}}
\renewcommand\cfttableleader{\nobreak}
\renewcommand\cfttabledotsep{\cftnodots}
\renewcommand\cfttableafterpnum{\hspace*{\fill}}
\setlength\cfttablenumwidth{12em}
\cftsetindents{table}{4em}{3em}
\renewcommand\cfttableformatpnum[1]{%
  \hskip1em\hbox to \@pnumwidth{{\cfttablepagefont #1\hfill}}}

% include after the change above (very important!)
\usepackage{titletoc}

\def\@endpart{
%
  \vfil
  \textcolor{red}{\hrule height 1.5 pt}
\setcounter{tocdepth}{0}

    \startcontents[parts]
    \printcontents[parts]{}{0}{} % change 0 to 1 etc. for more detail and vice versa

\textcolor{red}{\hrule height 1.5 pt}
  \par\bigskip
  \vfil\newpage
              \if@twoside
               \if@openright
                \null
                \thispagestyle{empty}%
                \newpage
               \fi
              \fi
              \if@tempswa
                \twocolumn
              \fi}
\makeatother
%%%

% be careful with the hyperref package; if colorlinks = true, then the (red) color in the chapter text in the TOC and  disappears! 
\usepackage{varioref,hyperref}
\hypersetup{
    bookmarks=true,                 % show bookmarks bar?
    unicode=false,                  % non-Latin characters in Acrobat’s bookmarks
    pdftoolbar=true,                % show Acrobat’s toolbar?
    pdfmenubar=true,                % show Acrobat’s menu?
    pdffitwindow=true ,             % window fit to page when opened
    pdfstartview={FitH},            % fits the width of the page to the window
    pdftitle={},                    % title
    pdfauthor={},   % author
    pdfsubject={},      % subject of the document
    pdfnewwindow=true,              % links in new window
    hidelinks=true,
    colorlinks=false,                   % false: boxed links; true: colored links
    linkcolor=black,                % color of internal links (change box color with linkbordercolor)
    citecolor=black,                % color of links to bibliography
    filecolor=black,                % color of file links
    urlcolor=aau-purple             % color of external links
}

\begin{document}

\frontmatter

    \tableofcontents*
    \cleardoublepage
    \listoffigures
    \cleardoublepage
    \listoftables
    \cleardoublepage

\chapter{Foreword}
Be careful about the URLs. Because the colorlinks is set to false (in the hypersetup in the preamble), this is how the URL will look like: \newline

\url{http://tex.stackexchange.com/posts/169068/edit} \newline

\noindent
If you would like to have the URLs in a specific colour, you have to manually colour code them: \newline

{\color{cyan}{\url{http://tex.stackexchange.com/posts/169068/edit}}} \newline

\noindent
However, If you do not care about the chapter  text colour in the TOC (if you want it black, which is standard), then the colorlinks can be set to true, which then should colour code the URLs automatically.


\mainmatter

\part{Designing with \TeX\ and \LaTeX}

\chapter{A test chapter}

\begin{figure}[H]
    \caption[(short) caption that goes to the LOF.]{(long) caption that goes below the figure}
\end{figure}

\begin{figure}[H]
    \caption[(short) caption that goes to the LOF.]{(long) caption that goes below the figure}
\end{figure}

\begin{figure}[H]
    \caption[(short) caption that goes to the LOF.]{(long) caption that goes below the figure}
\end{figure}

\begin{figure}[H]
    \caption[(short) caption that goes to the LOF.]{(long) caption that goes below the figure}
\end{figure}

\begin{figure}[H]
    \caption[(short) caption that goes to the LOF.]{(long) caption that goes below the figure}
\end{figure}

\chapter{Beginning to learn design with \TeX}
\section{Another test section}
\section{Another test section}

\begin{table}[H]
    \caption[(short) caption that goes to the LOT.]{(long) caption that goes below the figure}
\end{table}

\begin{table}[H]
    \caption[(short) caption that goes to the LOT.]{(long) caption that goes below the figure}
\end{table}

\begin{table}[H]
    \caption[(short) caption that goes to the LOT.]{(long) caption that goes below the figure}
\end{table}

\subsection{A test subsection}
\section{Another test section}
\subsection{A test subsection}
\subsection{A test subsection with a long title spanning more than one line in the table of contents}
\section{Another test section}
\section{Another test section}
\section{Another test section}



\chapter{Beginning to learn design with \LaTeX}
\section{A test section with a long title spanning more than one line in the table of contents}
\subsection{A test subsection}
\subsection{Another test subsection}
\section{A test section}
\phantomsection
\addcontentsline{toc}{section}{Test unnumbered section}
\section*{Test unnumbered section}
\subsection{A test subsection}
\section{Another test section}
\subsection{A test subsection}
\subsection{A test subsection}
\section{Another test section}
\section{Another test section}


\newpage\setcounter{page}{123}% just for the example

\part{Designing with HTML}

\chapter{Beginning to learn design with HTML and some other text to span more than one line}

\begin{figure}[H]
    \caption[(short) caption that goes to the LOF.]{(long) caption that goes below the figure}
\end{figure}

\begin{figure}[H]
    \caption[(short) caption that goes to the LOF.]{(long) caption that goes below the figure}
\end{figure}

\begin{figure}[H]
    \caption[(short) caption that goes to the LOF.]{(long) caption that goes below the figure}
\end{figure}

\section{Another test section}

\begin{table}[H]
    \caption[(short) caption that goes to the LOT.]{(long) caption that goes below the figure}
\end{table}

\begin{table}[H]
    \caption[(short) caption that goes to the LOT.]{(long) caption that goes below the figure}
\end{table}

\begin{table}[H]
    \caption[(short) caption that goes to the LOT.]{(long) caption that goes below the figure}
\end{table}

\section{Another test section}
\subsection{A test subsection}
\section{Another test section with a long title spanning more than one line in the table of contents}
\subsection{A test subsection}
\section{Another test section}



\chapter{Beginning to learn design with HTML and some other text to span more than one line} 
\section{Another test section}
\section{Another test section}
\subsection{A test subsection}
\subsection{A test subsection with a long title spanning more than one line in the table of contents}
\section{Another test section}
\section{Another test section}
\subsection{A test subsection}



\appendix

\chapter{Test Appendix}
\section{Another test section}

\begin{figure}[H]
    \caption[(short) caption that goes to the LOF.]{(long) caption that goes below the figure}
\end{figure}

\begin{figure}[H]
    \caption[(short) caption that goes to the LOF.]{(long) caption that goes below the figure}
\end{figure}

\begin{figure}[H]
    \caption[(short) caption that goes to the LOF.]{(long) caption that goes below the figure}
\end{figure}

\section{Another test section with a long title spanning more than one line in the table of contents}
\section{Another test section}

\begin{table}[H]
    \caption[(short) caption that goes to the LOT.]{(long) caption that goes below the figure}
\end{table}

\begin{table}[H]
    \caption[(short) caption that goes to the LOT.]{(long) caption that goes below the figure}
\end{table}

\begin{table}[H]
    \caption[(short) caption that goes to the LOT.]{(long) caption that goes below the figure}
\end{table}

\subsection{A test subsection}
\section{Another test section}
\section{Another test section}

\end{document}

The first two pages of the ToC:

enter image description here

The LoF:

enter image description here

The LoT:

enter image description here

share|improve this answer
    
Thanks a lot! Another thing I was thinking about (for additional tweaking) is how it would look like, if you also added the chapter + chapter number for each group of the captions, enclosed by the green vertical bar (only for the chapter + chapter number) just like in the TOC? –  poltexious Apr 4 at 1:54
    
@poltexious this is also possible and not too hard. I'll provide the code, but perhaps in some hours (it's almost bed time here). –  Gonzalo Medina Apr 4 at 1:59
    
No rush! (It's almost morning here) ;-) –  poltexious Apr 4 at 2:02
    
@poltexious please see my new answer. I had to give a different answer due to character restrictions :( –  Gonzalo Medina Apr 4 at 2:21
    
I really appreciate your invaluable answers! Thanks! I have one last question (I hope). 1) How can one center the chapter + chapter number according to the vertical line? Right now, it is not centered in the LOF and LOT as it is in the TOC. I tried to do it myself, but without luck. 2) Besides the chapter + chapter number, how can I also put the specific name of the chapter beneath the chapter + chapter number so that it looks the same way as in the TOC (also centered according to the green vertical linee)? –  poltexious Apr 4 at 9:21

Gonzalo Medina answered my questions very well. Since I would like to have the perfect alignment between the vertical (green) bar and the figure and table numbers in the LOF and LOT, respectively (just as in the TOC, but then it would be the section and subsection numbers), I decided to modify the:

  • \cftsetindents{figure}{6em}{3em} to \cftsetindents{figure}{5.25em}{3em} in the % redefinitions for figure entries code block
  • \cftsetindents{table}{6em}{3em} to \cftsetindents{table}{5.25em}{3em} in the % redefinitions for table entries code block

This minor modification aligns the vertical (green) line with the float number as seen below:


LOF


LOT


TOC


LOF/LOT


share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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