TransWikia.com

How to center customised lof name?

TeX - LaTeX Asked by FGHP on June 23, 2021

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}{%
    hfillbfseriesfontsize{16pt}{18pt}selectfontMakeTextUppercase%
  }

  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

One Answer

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 Largebfseries #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

Answered by Peter Wilson on June 23, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP