2

I have used the tocloft package to create a custom list of abbreviations. The layout in the list if fine. The problem that I have it that the command to create this entry creates a linebreak and I was after inline inclusion of the abbreviation.

The relevant code defining the list of abbreviations, as well as packages and a minimum of the preambule is as follows:

\RequirePackage{fix-cm}
\documentclass[a4paper,12pt,french]{report}
\usepackage[T1]{fontenc}
\usepackage[frenchb]{babel}
\usepackage[autolanguage]{numprint}
\usepackage[utf8]{inputenc}
\usepackage[top=2cm, bottom=2cm, left=2cm, right=2cm]{geometry}
\usepackage[extendedchars, babel, multidot]{grffile}
\usepackage{xcolor,graphicx}
\usepackage{tabularx, multirow, array}

\usepackage{hyperref}
\usepackage[nottoc, notlot, notlof]{tocbibind}
\usepackage[titles]{tocloft}

\newcommand{\listabrevname}{Liste des abréviations}
\newlistof[chapter]{abreviation}{abrev}{\listabrevname}
\newcommand{\abreviation}[2]{%
    \refstepcounter{abreviation}%
    \par\noindent\textnormal{#2  (#1)}%
    \addcontentsline{abrev}{abreviation}{%
        \protect\numberline{}#1 -- #2%
        }\par%
}
\cftsetindents{figure}{0em}{2.5em}
\cftsetindents{table}{0em}{2.5em}
\cftsetindents{abreviation}{0em}{0em}
\setlength{\cftbeforefigskip}{0.00em}
\setlength{\cftbeforetabskip}{0.00em}
\setlength{\cftbeforeabreviationskip}{1.0em}

\begin{document}

%a bunch of stuff%

\addtocontents{abrev}{\noindent\textbf{Abréviation}~\hfill\textbf{Première Apparition}\par}
\listofabreviation
\addcontentsline{toc}{chapter}{\protect\hphantom{\numberline{\thesection}}\listabrevname}%
\newpage

\renewcommand{\listfigurename}{Liste des figures}
\listoffigures
\addcontentsline{toc}{chapter}{\protect\hphantom{\numberline{\thesection}}\listfigurename}%
\addtocontents{lof}{\noindent\textbf{Figure}~\hfill\textbf{Page}\par}
\newpage
\listoftables
\addcontentsline{toc}{chapter}{\protect\hphantom{\numberline{\thesection}}\listtablename}%
\addtocontents{lot}{\noindent\textbf{Table}~\hfill\textbf{Page}\par}
\newpage

\addtocontents{toc}{~\hfill\hbox{}\par}
\tableofcontents

\newpage

chapter{Introduction}\label{Intro}
\pagenumbering{arabic}

The use of \abreviation{HA}{Acide hyaluronique} represents...

\end{document}

This gives:


.......Some text and some more text and some more text %line break - indented

Acide Hyaluronique (HA) (No indent)

.......The continuation of the text on yet another line... indented


I am looking for a continuous insertion of the abbreviation, so no linebreaks, which would give:


Some text and some more text and some more text Acide Hyaluronique (HA) Th continuation of the text on the same line.


I have tried introducing ~ to prevent a break, as well as the \nobreak, \nolinebreak at various places in the definition but have had no luck so far.

  • Welcome to TeX.SE. I don't understand why you want to glue one abbreviation appearance after another one the same line? How should this fit with the page of the first appearance then? I think you would get a better performance with packages like acro, acronym or glossaries. \addcontentsline causes new lines. –  Apr 14 '17 at 09:59
  • 1
    You have \pars in there which you don't want. This lets the abbrv. start a new paragraph at the beginning and the end of the abbrv.. Apart from that, you are reinventing the wheel. See the packages in the previous comment. – Johannes_B Apr 14 '17 at 10:18
  • @Johannes_B Thanks. it was the \pars - I didn't know they always generated new paragraphs. While these other packages are probably very effective. given i'd already defined other lists, this was more or less a copy paste minus this small issue. I also didn't want to end up with problems defining the way each title appears as I currently have 4+ \titleformat sections for each type of title. Feel free to post a proper answer so I can accept it, and any more détails about the way \par works would be appreciated for the future. – NzFrancis Apr 14 '17 at 10:55

0 Answers0