1

Does anyone know how I can add vertical and horizontal spacing between the entries of my LOF?

\documentclass[12pt,a4paper,twoside]{report} %openright

%Schriftart Arial - ACHTUNG: Compile with XeLaTeX (not PDFLaTeX)!
\usepackage{fontspec}
\defaultfontfeatures{Scale = MatchLowercase}
\setmainfont{Arial}[Scale = 1.0]

%Seitenlayout
\usepackage[top=2.5cm, bottom=2cm, left=2.5cm, right=2.5cm,paper=a4paper]{geometry}

%Deutsche Umlaute
\usepackage{ngerman}

%Zitierungen in der richtigen Reihenfolge
\usepackage{cite} 

%Längenangaben für den Abstand zwischen zwei Absätzen. 
\usepackage{parskip} 

%Zeilenabstand ändern
\usepackage[onehalfspacing]{setspace} 

%Farbige Texte etc
\usepackage{color} 

%Graphiken und Bilder
\usepackage{graphicx}
\usepackage{subfig}
\usepackage{psfrag}
\usepackage{wrapfig}

%Tabellenumgebung
\usepackage{tabularx}
\usepackage{booktabs} %\toprule, \midrule, \bottomrule

%Mathematische Symbole und Zeichen
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{mathrsfs}

%Algorithm Package
\usepackage[ruled,vlined]{algorithm2e}

%Kopfzeile
\usepackage{fancyhdr}

%Kapitelanzeige und -platzierung im Text
\usepackage[clearempty]{titlesec}
\titleformat{\chapter}{\normalfont\fontsize{16pt}{0}\bfseries}{\thechapter.}{9pt}{}
\titleformat{\section}{\normalfont\fontsize{14pt}{0}\bfseries}{\thesection}{9pt}{}
\titleformat{\subsection}{\normalfont\fontsize{12pt}{0}\bfseries}{\thesubsection}{9pt}{}
\titlespacing*{\chapter}{0pt}{-22pt}{4pt}



%Verzeichnisse
\usepackage[notindex, nottoc, numbib]{tocbibind} %TOC

\usepackage{tocbasic}

\DeclareTOCStyleEntry[
  indent=0pt,
  entrynumberformat=\useprefixfigure{\figurename},
  dynnumwidth,
  numsep=1em
]{tocline}{figure}
\newcommand\useprefixfigure[2]{#1\hspace{3pt}#2:\hfill}



%Formatierung Inhaltsverzeichnis
\usepackage{titletoc}
\contentsmargin{2em}
\dottedcontents{chapter}[21pt]{\addvspace{15pt}\bfseries}{20pt}{9.5pt}
\dottedcontents{section}[50pt]{\addvspace{3pt}}{2.3em}{9.5pt}
\dottedcontents{subsection}[89pt]{\addvspace{3pt}}{3.2em}{9.5pt}



% = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
% Formatierung der Kopfzeile
% = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
\setlength{\headheight}{0.6cm}

\pagestyle{fancy}
\fancyhf{}
\fancyhead[EL,OR]{\fontsize{8}{10} \selectfont \thepage}
\fancyhead[ER,OL]{\fontsize{8}{10} \selectfont \leftmark}
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}

\fancypagestyle{plain}{
\fancyhf{}
\fancyhead[EL,OR]{\fontsize{8}{10} \selectfont \thepage}
\fancyhead[ER,OL]{\fontsize{8}{10} \selectfont \nouppercase \leftmark}
}


% = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
\begin{document}
\listoffigures
\newpage

\begin{figure}[!ht]
  \centering
  \rule{2cm}{2cm}
  \caption{test figure one}
  \label{fig:test1}
\end{figure}

\begin{figure}[!ht]
  \centering
  \rule{2cm}{2cm}
  \caption{test figure two}
  \label{fig:test2}
\end{figure}


\end{document}

So for the horizontal spacing I figured that

\newcommand\useprefixfigure[2]{#1\hspace{3pt}#2:\hfill}

can be altered, but so far I just could adjust the space between "Abbildung" and e.g. "1.1" with \hspace{3pt}. I would like to have the "1.1" right next to the colon ":", and then a defined spacing to the title of the figure. But when I alter `\hfill, the colon suddenly isn't next "1.1" any more. Does someone have an idea why is that and what to do instead? And for the vertical space I am still pretty clueless...

Thanks in advance!

2

To add vertical space before each figure entry, use option beforeskip. I would suggest to add some glue too. The horizontal space between the widest figure number and its entry can be set by numsep:

\usepackage{tocbasic}
\DeclareTOCStyleEntry[
  indent=0pt,
  entrynumberformat=\useprefixfigure{\figurename},
  dynnumwidth,
  numsep=.5em,% <- changed
  beforeskip=3pt plus .2pt% <- added
]{tocline}{figure}
\newcommand\useprefixfigure[2]{#1\hspace{3pt}#2:\hfill}

You will get the same result with

\DeclareTOCStyleEntry[
  ...
  numsep=0pt,% <- changed
  ...
]{tocline}{figure}
\newcommand\useprefixfigure[2]{#1\hspace{3pt}#2:\hspace{.5em}\hfill}% <- changed

Example:

\documentclass[10pt,a4paper,twoside]{report} %openright

%Schriftart Arial - ACHTUNG: Compile with XeLaTeX (not PDFLaTeX)!
\usepackage{fontspec}
\defaultfontfeatures{Scale = MatchLowercase}
\setmainfont{Arial}[Scale = 1.0]
\usepackage[top=2.5cm, bottom=2cm, left=2.5cm, right=2.5cm,
  %paper=a4paper,% not needed because of the class option a4paper
  headheight=.6cm% set headheight by geometry
]{geometry}
\usepackage[ngerman]{babel}%package ngerman is deprecated
\usepackage{cite} 
\usepackage{parskip} 
\usepackage[onehalfspacing]{setspace} 
\usepackage{color} 
\usepackage{graphicx}
\usepackage{subfig}
\usepackage{psfrag}
\usepackage{wrapfig}
\usepackage{tabularx}
\usepackage{booktabs}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{mathrsfs}
\usepackage[ruled,vlined]{algorithm2e}
\usepackage{fancyhdr}
\usepackage[clearempty]{titlesec}
\titleformat{\chapter}{\normalfont\fontsize{16pt}{0}\bfseries}{\thechapter.}{9pt}{}
\titleformat{\section}{\normalfont\fontsize{14pt}{0}\bfseries}{\thesection}{9pt}{}
\titleformat{\subsection}{\normalfont\fontsize{12pt}{0}\bfseries}{\thesubsection}{9pt}{}
\titlespacing*{\chapter}{0pt}{-22pt}{4pt}
\usepackage[notindex, nottoc, numbib]{tocbibind} %TOC

\usepackage{tocbasic}
\DeclareTOCStyleEntry[
  indent=0pt,
  entrynumberformat=\useprefixfigure{\figurename},
  dynnumwidth,
  numsep=.5em,% <- changed
  beforeskip=3pt plus .2pt% <- added
]{tocline}{figure}
\newcommand\useprefixfigure[2]{#1\hspace{3pt}#2:\hfill}

\DeclareTOCStyleEntry[
  linefill=\bfseries\TOCLineLeaderFill,
  numwidth=1.7em,
  indent=1pt,
  beforeskip=15pt plus 1pt
]{tocline}{chapter}
\DeclareTOCStyleEntry[
  indent=1.87em,
  beforeskip=3pt plus .2pt
]{tocline}{section}
\DeclareTOCStyleEntry[
  indent=4.22em,
  beforeskip=3pt plus .2pt
]{tocline}{subsection}

\makeatletter
\renewcommand\@tocrmarg{2em}
\makeatother

\pagestyle{fancy}
\fancyhf{}
\fancyhead[EL,OR]{\fontsize{8}{10} \selectfont \thepage}
\fancyhead[ER,OL]{\fontsize{8}{10} \selectfont \leftmark}
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}

\fancypagestyle{plain}{
\fancyhf{}
\fancyhead[EL,OR]{\fontsize{8}{10} \selectfont \thepage}
\fancyhead[ER,OL]{\fontsize{8}{10} \selectfont \nouppercase \leftmark}
}

\usepackage{blindtext}% only for dummy text in the example

\begin{document}
\tableofcontents
\listoffigures

\blinddocument
\begin{figure}[!ht]
  \centering
  \rule{2cm}{2cm}
  \caption{test figure one}
  \label{fig:test1}
\end{figure}
\begin{figure}[!ht]
  \centering
  \rule{2cm}{2cm}
  \caption{test figure two}
  \label{fig:test2}
\end{figure}
\end{document}

Run three times to get

enter image description here

  • Thank you very much for the explanation, the updated code and the annotations! – TeXlearner Jun 2 at 15:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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