0

I would like to place a victorian ornament (pgfornament 80) below List of Algorithms, References, and Index, all centered and capitalized. Below is my minimal working example (MWE), but the ornament is frustratingly misplaced. Please help.

\documentclass[a4paper,12pt]{book}
\usepackage[utf8]{inputenc}
\usepackage{lipsum}
\usepackage{algorithm2e}
\usepackage[object=vectorian]{pgfornament}
\usepackage{imakeidx}
\makeindex

\title{Question} \author{Author} \date{August 2021}

\begin{document}

\maketitle

\tableofcontents

\clearpage \addcontentsline{toc}{chapter}{LIST OF ALGORITHMS} %\centering {\rule{\textwidth}{1pt} \vspace{-1.5cm}} \renewcommand{\listalgorithmcfname}{\hfill LIST OF ALGORITHMS \hfill}

\begin{center} \pgfornament[width=4cm]{80} \end{center}

{% \let\oldnumberline\numberline% \renewcommand{\numberline}{\algorithmcfname~\oldnumberline}% \listofalgorithms }

\newpage \chapter{Introduction} \lipsum[1] \

\begin{algorithm}[H] \SetAlgoLined \KwData{this text} \KwResult{how to write algorithm with \LaTeX2e } initialization; \While{not at end of this document}{ read current; \eIf{understand}{ go to next section; current section becomes this one; }{ go back to the beginning of current section; } } \caption{How to write algorithms} \end{algorithm}

\section{BibTex}

This document is an example of BibTeX using in bibliography management. Three items are cited: \textit{The \LaTeX\ Companion} book \cite{latexcompanion}, the Einstein journal paper \cite{einstein}, and the Donald Knuth's website \cite{knuthwebsite}. The \LaTeX\ related items are \cite{latexcompanion,knuthwebsite}.

\index{Einstein}

\medskip

\renewcommand{\bibname}{ REFERENCES } \bibliographystyle{unsrt} \bibliography{ref}

\printindex

\end{document}

Sam Macharia
  • 103
  • 4

1 Answers1

0

You may want to use the titlesec package to style your numberless \chapter headings; see e.g. Titlesec for numberless commands

So you might try something like this:

% Load the titlesec package
\usepackage{titlesec}

% Styling numberless chapter headings \titleformat{name=\chapter,numberless} {\Huge\bfseries} {}{0pt} {\filcenter\MakeUppercase} [{\filcenter\pgfornament[width=4cm]{80}}]

% But you'll need to provide for numberred headings too; so % here I'm just using the default style \titleformat{name=\chapter}[display] {\Huge\bfseries} {\chaptername~\thechapter}{\baselineskip} {}

(In your code, the \\ after \lipsum[1] should be removed)

imnothere
  • 14,215
  • Thank you. This is what I was hoping to do. However, when I try to do the same in my huge document, some chapter titles such as LIST OF ALGORITHMS and ACKNOWLEDGMENT disappear, but the ornament remains. It turns out my MWE was oversimplified. I'll make another MWE. If you have a hint kindly let me know. – Sam Macharia Aug 05 '21 at 11:19
  • The following worked for me in the cases that the above could not work: \chapter*{INDICES} \addcontentsline{toc}{chapter}{INDICES} \begin{center} \color{black} \pgfornament[width=4cm]{80} \end{center} \printindex – Sam Macharia Aug 11 '21 at 00:33