0

I am creating a template for use in Report document class with pdfLaTeX compiler in Overleaf. The template specifications are specific for the agency, so there are a lot of specifications.

The minimum reproducible example has the full styling because some packages/commands conflict when used in isolation.

My question is: on the List of Figures, how can I force the indent/alignment for figure captions that spill over onto the next line?

UPDATE

I don't want to use tocloft because it removes a lot of the other formatting and conflicts with titletoc and titlesec packages, which must be used.

How can I modify

{\let\oldnumberline\numberline %
        \renewcommand{\numberline}{\figurename~\oldnumberline} %
        \listoffigures}

to force the alignment/indent on the second line?

enter image description here

Here is the code, which makes a 7 page PDF. The preamble that formats the insert List of Figures is commented with % ================ Need help here I think

%-------------------------------------------------------
% Dummy Chapter 1
\begin{filecontents*}[overwrite]{ChapterA.tex}
\chapter{Introduction}
\lipsum[1]
\section{Section Name}
Here is some text, see Figure \ref{fig:a}.
\begin{figure}
  \centering
  \includegraphics[width = 0.5\textwidth]{example-image-a}
  \caption[And example figure with a shorter description that still spills over onto the next line. How can I fix the indent?]{An example figure with a long description, many more important words here.} 
  \label{fig:a}
\end{figure}
\subsection{Subsection Name}
Here is a subsection, see \cite{einstein1906new}.
\end{filecontents*}

%-------------------------------------------------------
% Dummy Abstract
\begin{filecontents*}[overwrite]{Abstract.tex}
\cleardoublepage
\addcontentsline{toc}{chapter}{Abstract}
\begin{center}
  \fontsize{18pt}{0pt}\selectfont\MakeUppercase{\textbf{abstract}}
\end{center}

\vspace*{24pt}

This is the abstract.
\end{filecontents*}

%-------------------------------------------------------
% Dummy References
\begin{filecontents*}{refs.bib}
@article{einstein1906new,
  title={A new determination of molecular dimensions},
  author={Einstein, Albert},
  journal={Ann. Phys.},
  volume={19},
  pages={289--306},
  year={1906}
}
\end{filecontents*}

%-------------------------------------------------------
% Preamble
\documentclass[12pt]{report}
\usepackage[utf8]{inputenc}
\usepackage{nameref}
\usepackage{mathtools}
\usepackage{amsmath, amsthm, amssymb, amsfonts}
\usepackage{graphicx}
\usepackage{booktabs}
\usepackage{threeparttable}
\usepackage{subcaption}
\usepackage{natbib}
\usepackage{appendix}
\usepackage{lipsum}

% set page & paragraph dimensions
\usepackage[letterpaper, margin=1in]{geometry}
\setlength{\parindent}{0.5in}
\setlength{\parskip}{6pt}

% set font
\usepackage[sfdefault]{carlito}

% set-up frontmatter, mainmatter, backmatter
\makeatletter
\newcommand\frontmatter{
    \cleardoublepage
    \pagenumbering{roman}}
\newcommand\mainmatter{
    \cleardoublepage
    \pagenumbering{arabic}}
\newcommand\backmatter{
    \if@openright
        \cleardoublepage
    \else
        \clearpage
    \fi
}
\makeatother

% format headers
\usepackage{titlesec}

\newcommand{\chapterjustification}{}
\newcommand{\chapterfont}{\normalfont}
\newcommand{\chapterfontsize}{\fontsize{22pt}{0pt}\selectfont}

\titleformat{\chapter}%
    {\chapterjustification\chapterfont\chapterfontsize\bfseries\MakeUppercase}%
    {\thechapter}{0.5in}{}
\titlespacing*{\chapter}{0pt}{80pt}{40pt}

\titleformat{\section}%
    {\normalfont\fontsize{14pt}{0pt}\selectfont\bfseries\MakeUppercase}%
    {\thesection}{0.5in}{}
\titlespacing*{\section}{0pt}{24pt}{12pt}

\titleformat{\subsection}%
    {\normalfont\fontsize{14pt}{0pt}\selectfont\bfseries}%
    {\thesubsection}{0.5in}{}
\titlespacing*{\subsection}{0pt}{18pt}{12pt}

% format table of contents
\usepackage{titletoc}
\contentsmargin{0.2in}

\titlecontents{chapter}[0.5in]{%
    \addvspace{12pt}\bfseries}{%
    \contentslabel{0.5in}\MakeUppercase}{%
    \hspace*{-0.5in}\MakeUppercase}{%
    \titlerule*[0.5pc]{.}\contentspage} % dot density

\titlecontents{section}[1in]{\bfseries}{%
    \contentslabel{0.5in}\MakeUppercase}{%
    \hspace*{-1in}\MakeUppercase}{%
    \titlerule*[0.5pc]{.}\contentspage}
    
\titlecontents{subsection}[1.5in]{\selectfont}{%
    \contentslabel{0.5in}}{%
    \hspace*{-1in}}{%
    \titlerule*[0.5pc]{.}\contentspage}

\newcommand{\insertTOC}{\begingroup
    \cleardoublepage
    \addcontentsline{toc}{chapter}{Contents}
    \renewcommand{\chapterjustification}{\centering}
    \renewcommand{\chapterfontsize}{\fontsize{16pt}{0pt}\selectfont}
    \titlespacing*{\chapter}{0pt}{0pt}{24pt}
    \tableofcontents
    \endgroup}

% format list of figures & list of tables pages
% ================ Need help here I think (below)
\newcommand{\insertLOF}{\begingroup
    \cleardoublepage
    \addcontentsline{toc}{chapter}{List of Figures}
    \renewcommand{\chapterjustification}{\centering}
    \renewcommand{\chapterfontsize}{\fontsize{16pt}{0pt}\selectfont}
    \titlespacing*{\chapter}{0pt}{0pt}{24pt}
    {\let\oldnumberline\numberline %
        \renewcommand{\numberline}{\figurename~\oldnumberline} %
        \listoffigures}
    \endgroup}
% ================ Need help here I think (above)

\newcommand{\insertLOT}{\begingroup
    \cleardoublepage
    \addcontentsline{toc}{chapter}{List of Tables}
    \renewcommand{\chapterjustification}{\centering}
    \renewcommand{\chapterfontsize}{\fontsize{16pt}{0pt}\selectfont}
    \titlespacing*{\chapter}{0pt}{0pt}{24pt}
    {\let\oldnumberline\numberline %
        \renewcommand{\numberline}{\tablename~\oldnumberline} %
        \listoftables}
    \endgroup}

% load hyperref last to minimize conflicts
\usepackage{xcolor}
\usepackage[linktocpage=true]{hyperref}
\hypersetup{colorlinks=true, linkcolor=blue, citecolor=blue}

%-------------------------------------------------------
\begin{document}

\frontmatter
\include{Abstract}
\insertTOC
\insertLOF
\insertLOT

\mainmatter
\include{ChapterA}

\backmatter
\bibliographystyle{plain}
\bibliography{refs}


\end{document}
%-------------------------------------------------------
1
  • 1
    I assume titlesec can also affect the formatting of \l@figure. Personally, I find it easier to NOT use packages like titlesec. Nov 16, 2021 at 3:05

1 Answer 1

0

I don't really understand your code but I have fiddled around with the \insertLOF code, and also used the tocloft package to get a better LoF.

% format list of figures & list of tables pages
% ================ Need help here I think (below)
\newcommand{\insertLOF}{\begingroup
    \cleardoublepage
    \addcontentsline{toc}{chapter}{List of Figures}
    \renewcommand{\chapterjustification}{\centering}
    \renewcommand{\chapterfontsize}{\fontsize{16pt}{0pt}\selectfont}
    \titlespacing*{\chapter}{0pt}{0pt}{24pt}
    {\let\oldnumberline\numberline %
        \renewcommand{\numberline}{\figurename~\oldnumberline} %
        \listoffigures}
    \endgroup}
% ================ Need help here I think (above)

% and here it is --- Peter W.
\usepackage{tocloft}
\renewcommand{\cftloftitlefont}{\hfill\Large}
\renewcommand{\cftafterloftitle}{\hfill}

\renewcommand{\insertLOF}{%
  \cleardoublepage
  \addcontentsline{toc}{chapter}{List of Figures}
  \listoffigures
}

You should do something similar for \insertLOT.

I feel that the code you show is unnecessarily complicated (detailed), but then I'm a GOM (Grumpy Old Man). Why not try the memoir class (a superset of book and report) which, for example, can automatically add the LoF and LoT titles to the ToC?

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .