MakeIndex, Nomenclature, Glossaries and AcronymsHow to add a horizontal rule after "List of Acronyms" using glossaries package?

Information and discussion about MakeIndex - the tool to generate subject indices for LaTeX documents.
Post Reply
Septic6110
Posts: 2
Joined: Thu Mar 06, 2025 2:06 pm

How to add a horizontal rule after "List of Acronyms" using glossaries package?

Post by Septic6110 »

I am writing my thesis using the `report` class in LaTeX. The Table of Contents (`\tableofcontents`) includes a horizontal rule below its title, using the

Code: Select all

\renewcommand\cftaftertoctitle
command. However, when I generate the List of Acronyms using `\printnoidxglossary[type=\acronymtype]` from the `glossaries` package, there is no horizontal rule below its title, and I do not know how to do this. I have included the MWE below using a standard thesis template and other packages.

Code: Select all

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

\usepackage[a4paper]{geometry}
\geometry{verbose,tmargin=1in,bmargin=1in,lmargin=1.25in,rmargin=1in}
\usepackage{authblk,lineno,url,sectsty}
\usepackage[dvipsnames]{xcolor}
\usepackage{lipsum}

\usepackage{emptypage}
\renewcommand{\bibname}{References}
\usepackage{array,float,multirow,graphicx,setspace,cite,url,titlesec,tocloft}

\usepackage{datetime}
\usepackage{amsmath,amsfonts,mathtools,notoccite}
\usepackage{chngcntr,pdflscape,enumitem,algorithm,algorithmic, subcaption}
\usepackage{bm}

\usepackage[colorlinks=true, urlcolor=cyan, citecolor=blue]{hyperref}
\usepackage{cleveref}

\usepackage[acronym,nogroupskip,style=long3col]{glossaries}
\makenoidxglossaries
\setacronymstyle{long-sc-short}
%%%%%%% Header-Footer %%%%%%%%%%%%%%%
\usepackage{fancyhdr}\pagestyle{fancy}
\fancyhf{}
\fancyhead[LE]{\rightmark}
\fancyhead[RO]{\leftmark}
\fancyfoot[C]{\thepage}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\renewcommand{\sectionmark}[1]{\markright{#1}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\numberwithin{equation}{section}
\linespread{1.3}

\titleformat{\chapter}[display]
{\normalfont \huge \filleft \bfseries}{\chaptertitlename\ \thechapter}{8pt}{\LARGE}
\titlespacing*{\chapter}{0pt}{0pt}{10pt}

\renewcommand\cftaftertoctitle{\par\noindent\rule{\textwidth}{2pt}\par\vskip-3.0em}
\renewcommand\cftafterloftitle{\par\noindent\rule{\textwidth}{2pt}\par\vskip-3.0em}
\renewcommand\cftafterlottitle{\par\noindent\rule{\textwidth}{2pt}\par\vskip-3.0em}

\newdateformat{monthyeardate}{\monthname[\THEMONTH], \THEYEAR}

\newacronym{cad}{CAD}{Computer-Aided Diagnosis}
\newacronym{dl}{DL}{Deep Learning}
\newacronym{latex}{LaTeX}{I love LaTeX}

\begin{document}

	\pagestyle{plain}
	%%%%%%%%%%%%%%%%%%%  Title page %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
	\pagenumbering{roman}
	\begin{center}
		\vspace{10mm}
		\Large {\textcolor{black}{\textbf{my thesis}}} \\
		\vspace{10mm}
		\large {\textbf{A Thesis}}\\
		\vspace{3mm}
		\normalsize {\textit{\textbf{Submitted in the partial fulfillment of the requirements} \\ \textit{\textbf{for the award of the degree of}}}} \\
		\vspace{3mm}
		\large {\textbf{\monthyeardate\today}}
	\end{center}
	\thispagestyle{empty}
	\cleardoublepage                        % for the blank page
	%%%%%%%%%%%%%%%%%%%  Certificate page %%%%%%%%%%%%%%%%%%%%%%%%%%%%
	\vspace{-2.5\baselineskip}
	\begin{center}
		{\bf\Large \underline{CANDIDATE'S DECLARATION}}\\
		%\par
		%\vspace{5mm}
	\end{center}
	\lipsum[2-4]
	\addcontentsline{toc}{chapter}{Certificate} 
	\cleardoublepage
	%%%%%%%%%%%%%%%%%%% Dedication page %%%%%%%%%%%%%%%%%%%%%%%%%%%%
	\chapter*{}
	\thispagestyle{empty}
	\begin{center}
		\vfill
		{\Huge \textbf{Dedicated to \LaTeX} }
		\vfill 
	\end{center}
	\addcontentsline{toc}{chapter}{Dedication}
	\cleardoublepage
	%%%%%%%%%%%%%%%%%%% Acknowledgement page %%%%%%%%%%%%%%%%%%%%%%%%%%
	\vspace{-6.0\baselineskip}
	\textbf{\begin{flushright}
			{\LARGE \textbf{ACKNOWLEDGMENTS}}
	\end{flushright}}
	\vspace{-0.5\baselineskip}
	\noindent\rule{\linewidth}{2pt}
	\lipsum[2-4]
	
	\addcontentsline{toc}{chapter}{Acknowledgments}
	\cleardoublepage
	%%%%%%%%%%%%%%%%%%% Abstract page %%%%%%%%%%%%%%%%%%%%%%%%%%%%
	\vspace{-4.0\baselineskip}
	\textbf{\begin{flushright}
			{\LARGE \textbf{ABSTRACT}}
	\end{flushright}}
	\vspace{-0.5\baselineskip}
	\noindent\rule{\linewidth}{2pt}
	\lipsum[2-4]
	
	\addcontentsline{toc}{chapter}{Abstract}
	\cleardoublepage
	%%%%%%%%%%%%%%%%%%% Table of contents %%%%%%%%%%%%%%%%%%%%%%%%%%%%
	\begin{flushright}
		\tableofcontents
	\end{flushright}
	\cleardoublepage
	%%%%%%%%%%%%%%%%%%% Table of figures %%%%%%%%%%%%%%%%%%%%%%%%%%%%
	\begin{flushright}
		\listoffigures
		\addcontentsline{toc}{chapter}{List of Figures}
	\end{flushright}	
	\cleardoublepage
	%%%%%%%%%%%%%%%%%%% List of Tables %%%%%%%%%%%%%%%%%%%%%%%%%%%%
	\begin{flushright}
		\listoftables
		\addcontentsline{toc}{chapter}{List of Tables}
	\end{flushright}
	\cleardoublepage
	%%%%%%%%%%%%%%%%%%% Table of acronyms %%%%%%%%%%%%%%%%%%%%%%%%%%%%
	\addcontentsline{toc}{chapter}{List of Acronyms}
	\printnoidxglossary[type=\acronymtype,title={\huge List of Acronyms}]
	\cleardoublepage	
	%-----
	\pagestyle{fancy}
	%----
	%%%%%%%%%%%%%% Chapters 1 %%%%%%%%%%%%%%
	\pagenumbering{arabic}
	%	\doublespacing
	\chapter{Introduction}
	\noindent\rule{\linewidth}{2pt}
	\lipsum[2-4]
	\section{Background and Motivation} 
	\gls{dl}, \gls{cad}, \cite{lamport94}. The domain of monitoring the Earth's physical, chemical, and biological systems from space is generally known as Earth Observation (EO)
	\cleardoublepage
	%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Chapter-2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
	\chapter{Methods}
	\noindent\rule{\linewidth}{2pt}
	\lipsum[2-10]
	\section{Motivation} 
	\gls{latex} The domain of monitoring the Earth's physical, chemical, and biological systems from space is generally known as Earth Observation (EO)
	\cleardoublepage
	%	%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
	%	\printacronyms
	%	\printnoidxglossary[type=\acronymtype,title={\huge List of Abbreviations},nonumberlist]
	
	\addcontentsline{toc}{chapter}{References}
%	\bibliography{}	
\begin{thebibliography}{9}
	\bibitem{texbook}
	Donald E. Knuth (1986) \emph{The \TeX{} Book}, Addison-Wesley Professional.
	
	\bibitem{lamport94}
	Leslie Lamport (1994) \emph{\LaTeX: a document preparation system}, Addison
	Wesley, Massachusetts, 2nd ed.
\end{thebibliography}
\end{document}

I want to achieve the following:
1. A horizontal rule appears below "**List of Acronyms**", just like it does for the **Table of Contents**.
2. Similarly, a horizontal rule appears below **References**.

Efforts: I have included the following line

Code: Select all

\printnoidxglossary[type=\acronymtype, title=\vspace{-1mm}{\vspace{0.7\baselineskip} \huge List of Acronyms \vspace{-0.3\baselineskip} \rule{\linewidth}{2pt}}]
But this is a very hacky way, and it still has not achieved the effect, as there is some vertical space (when you run the MWE), and the visual appearance is not similar to the List of tables or List of figures—any better way of doing this.
Last edited by Septic6110 on Sat Mar 08, 2025 5:54 am, edited 7 times in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
Bartman
Posts: 366
Joined: Fri Jan 03, 2020 2:39 pm

Re: How to add a horizontal rule after "List of Acronyms" using glossaries package?

Post by Bartman »

Please remove the (two) obstacles that prevent your example from running without errors. It is also welcomed if you share your crossposts.

Have a look at the last optional argument of the \titleformat command in the titlesec package manual.
Septic6110
Posts: 2
Joined: Thu Mar 06, 2025 2:06 pm

Re: How to add a horizontal rule after "List of Acronyms" using glossaries package?

Post by Septic6110 »

Thank you for your response. I have removed the obstacles, and the code is running fine now. My bad for not testing in the first place. This is my first post in this forum. Here is a similar question that I have asked in a similar forum.
https://tex.stackexchange.com/questions ... of-conten
I could produce a horizontal rule, but the white space between the rule and the titles is excessive when you compare it with another listing like "List of Figures" and "List of Tables" (as you can see in the output pdf).

The horizontal rule is achieved using command.

Code: Select all

\cftafterloftitle
I could not find any similar command in the glossaries package.
I have partially achieved my objective, and it probably works fine, but if there is any other method that can give me the stated output, it would be nice.

Please share if there is any way to use glossaries or another package.
Post Reply