Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I use the acronym package with page numbers. Now I would like to have the dots between the acronym and the page number in same style as in the ListofTables: same spacing between the dots and between the last dot and the page number.
The line spacing should be the same as well, but the dots have the higher priority.
(In addition the alignment among the acronyms does not seem to work well in the mini example, but fine in my document.)

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[printonlyused,withpage]{acronym}
\begin{document}
\parskip 6pt% space between paragraphs
\renewcommand{\baselinestretch}{1.2}\normalsize% leading -- space between two lines
\renewcommand{\bflabel}[1]{\normalfont{\normalsize\bf{#1}}\hfill}% font adjustment
\section*{List of Abbreviations}
\begin{acronym}[MSC]
\acro{IMO}{International Maritime Organization}
\acro{MSC}{Maritime Safety Committee}
\end{acronym}
\listoftables
\begin{table}\begin{tabular}{c} \ac{MSC}\end{tabular}\caption{a}\end{table}
\begin{table}\begin{tabular}{c} \ac{IMO}\end{tabular}\caption{b}\end{table}
\end{document}
share|improve this question
    
Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. –  karlkoeller Feb 6 at 11:49

1 Answer 1

up vote 4 down vote accepted

Add the following code to your preamble:

\usepackage{etoolbox}
\makeatletter
\patchcmd{\AC@@acro}
  {\dotfill\pageref{acro:#1}}
  {\nobreak\leaders\hbox{$\mkern -7mu \mkern \@dotsep mu\hbox{.}\mkern \@dotsep mu \mkern 7mu$}%
   \hfill\nobreak\makebox[1.3em][r]{\pageref{acro:#1}}}
  {}
  {}
\makeatother

In this way we patch the command responsible of writing the lines in the acronym list to behave like the one responsible for placing the lines in the LoT.

Complete MWE:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[printonlyused,withpage]{acronym}

\usepackage{etoolbox}
\makeatletter
\patchcmd{\AC@@acro}
  {\dotfill\pageref{acro:#1}}
  {\nobreak\leaders\hbox{$\mkern -7mu \mkern \@dotsep mu\hbox{.}\mkern \@dotsep mu \mkern 7mu$}%
   \hfill\nobreak\makebox[1.3em][r]{\pageref{acro:#1}}}
  {}
  {}
\makeatother

\begin{document}
\parskip 6pt% space between paragraphs
\renewcommand{\baselinestretch}{1.2}\normalsize% leading -- space between two lines
\renewcommand{\bflabel}[1]{\normalfont{\normalsize\bf{#1}}\hfill}% font adjustment
\section*{List of Abbreviations}
\begin{acronym}[MSC]
\acro{IMO}{International Maritime Organization}
\acro{MSC}{Maritime Safety Committee}
\end{acronym}
\listoftables
\begin{table}\begin{tabular}{c} \ac{MSC}\end{tabular}\caption{a}\end{table}
\begin{table}\begin{tabular}{c} \ac{IMO}\end{tabular}\caption{b}\end{table}
\end{document}

Output:

enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.