3

I'm using the package acronym to handle acronyms in my document. Unfortunately, when expanding them inside a table they become shifted downwards. Here's a minimal example:

\documentclass{article}
\usepackage[nolist]{acronym}
\begin{document}

\begin{acronym}
  \acro{LONG1}{My extra super long acronym}
  \acro{LONG2}{Yet another very long acronym}
\end{acronym}

\begin{tabular}{ | p{3cm} | p{3cm} |}
  \hline
  \ac{LONG1} & Line 1 \\ \hline
  \ac{LONG2} & Line 2 \\ \hline
\end{tabular}

\end{document}

Table example

Ideally, I'd like them to be aligned to the top and not justified. How can I achieve that?

3
  • 1
    To suppress justification, be sure to load the array package and change p{3cm} to >{\raggedright\arraybackslash}p{3cm}.
    – Mico
    Sep 26, 2020 at 22:05
  • Thank you @Mico!
    – sidyll
    Sep 26, 2020 at 22:09
  • I have the same issue, but this response did not work. Any other method? Jun 21, 2022 at 21:47

1 Answer 1

2

Every time an acronym is used, a line \acronymused{...} is written to the aux file. This introduces a whatsit node which doesn't behave well in vertical mode, like at the start of a p cell. You see the same behaviour here:

\documentclass{article}

\makeatletter
\newcommand*{\foo}{\write\@auxout{\@percentchar hello world}foo}
\makeatother

\begin{document}

\begin{tabular}{ | p{3cm} | p{3cm} | }
\hline
\foo & Line 1 \\ \hline
\leavevmode\foo & Line 2 \\ \hline
\end{tabular}

\end{document}

enter image description here

To avoid the problem you should start horizontal mode before using \ac by writing \leavevmode (or \mbox{}) at the start of the incriminated cells:

\documentclass{article}
\usepackage[nolist]{acronym}
\begin{document}

\begin{acronym}
  \acro{LONG1}{My extra super long acronym}
  \acro{LONG2}{Yet another very long acronym}
\end{acronym}

\begin{tabular}{ | p{3cm} | p{3cm} | }
  \hline
  \leavevmode\ac{LONG1} & Line 1 \\ \hline
  \leavevmode\ac{LONG2} & Line 2 \\ \hline
\end{tabular}

\end{document}

enter image description here

The acronym package should either start its typesetting macros with \leavevmode, or move the \write after the acronym has been typeset.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .