0

How to center customised lof name ?

I need to control lof style. I need :

  • lof name to be centered with given style (font, color, ...)
  • space after lof name
  • centered line (not spanning the whole page)
  • space after line

Trying this

~\lof> more .\lof.tex
\documentclass[letterpaper,10pt]{report}
\usepackage{fontspec}

\newcommand{\lof}{
  \renewcommand{\listfigurename}{%
    \centering%
    \fontsize{16pt}{18pt}\selectfont \textbf{MY LIST OF FIG}%
    \newline%
    \centering%
    \vspace*{0.3cm}%
    {\rule{3cm}{0.8pt}}%
    \vspace*{0.3cm}%
  }
  \listoffigures
}

\begin{document}
\lof
\end{document}

gives

enter image description here

Which is not centered as expected. Trying this :

~\lof> more .\lof2.tex
\documentclass[letterpaper,10pt]{report}
\usepackage{fontspec}

\newcommand{\lof}{
  \renewcommand{\listfigurename}{%
    \begin{center}%
    \fontsize{16pt}{18pt}\selectfont \textbf{MY LIST OF FIG}%
    \newline%
    \vspace*{0.3cm}%
    {\rule{3cm}{0.8pt}}%
    \vspace*{0.3cm}%
    \end{center}%
  }
  \listoffigures
}

\begin{document}
\lof
\end{document}

Does not help (getting exact same result).

UPDATE 1

This does not help either

~\lof> more lof.tex
\documentclass[letterpaper,10pt]{report}
\usepackage{tocloft}
\usepackage{fontspec}

\newcommand{\lof}{
  \renewcommand{\listfigurename}{%
    \textbf{MY LIST OF FIG}%
  }
  \renewcommand{\cftloftitlefont}{%
    \centering%
    \fontsize{16pt}{18pt}\selectfont%
  }
  \renewcommand{\cftafterloftitle}{%
    \centering%
    \newline%
    \vspace*{0.3cm}%
    {\rule{3cm}{0.8pt}}%
    \vspace*{0.3cm}%
  }
  \listoffigures
}

\begin{document}
\lof
\end{document}

Which gives

enter image description here

UPDATE 2

Does not work either

~\lof> more .\lof.tex
\documentclass[letterpaper,10pt]{report}
\usepackage{tocloft}
\usepackage{fontspec}
\usepackage{textcase}

\newcommand{\lof}{
  \newlength{\lofnamel}
  \renewcommand{\listfigurename}{%
    my list of fig%
  }
  \settowidth{\lofnamel}{\listfigurename}

  \renewcommand{\cftloftitlefont}{%
    \hfill\bfseries\fontsize{16pt}{18pt}\selectfont\MakeTextUppercase%
  }

  \renewcommand{\cftafterloftitle}{
    \\%
    \vspace*{0.3cm}%
    \centering {\rule{3cm}{0.8pt}}%
    \vspace*{0.3cm}%
  }
  \listoffigures
}

\begin{document}
\lof
\end{document}

Which gives

enter image description here

Franck

1 Answer 1

1

If you would be willing to switch to the memoir class (a superset of book and report) then this gives you the basics of what I think you want.

% loftitleprob.tex  SE 598988

\documentclass[letterpaper,10pt]{memoir}
\usepackage{fontspec}

\usepackage{lipsum}

\newlength{\lofnamel}
\renewcommand{\listfigurename}{MY LIST OF FIG}
\settowidth{\lofnamel}{\listfigurename}

\renewcommand{\printloftitle}[1]{%
  \centering \Large\bfseries #1 \\ \rule{\lofnamel}{0.1em}}

\begin{document}
\listoffigures

\begin{comment} % stuff below adds text and a figure
\lipsum[1]

\begin{figure}
\centering
FIGURE
\caption{A figure}
\end{figure}
\end{comment}

\end{document}

enter image description here

1
  • Ideally I need to stick to report : the stylesheet is unfortunately not mine, it's imposed to me by some company. I guess memoir does the job and defines \printloftitle right ? I get ! LaTeX Error: Command \printloftitle undefined. when I tried with report... Where to find the code of \printloftitle : may be adding this to report would work ?
    – fghoussen
    Commented May 30, 2021 at 6:16

You must log in to answer this question.

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