11

I have written my whole document without using any packages like nomencl or acronym because it wasn't necessary in my case, that means I only have a few abbreviations which should fit on one page easily.

I'd like to do that by hand, that means manually within a tabular (or maybe longtable?) environment. The problem is, I cannot fix the abbreviations column on the left while at the same time increasing the distance to the column on the right. If possible I'd like to fill the distance with cdot.

So the list should consist of 2 columns, the left fixed with variable/changable distance to the right.

Here is my MWE with tabularx. You will see the prob if you compile: every word fills 2 lines instead of just one if the distance is too small (in this case 3cm).

\documentclass[a4paper, 12pt, headsepline, smallheadings]{scrreprt}
\usepackage{tabularx}
\begin{document}
\begin{tabularx}{3cm}{XX}
US  & United States \\
EU & European Union \\
Gvmt & Government \\
\end{tabularx}
\end{document}

Let me know. If it's not possible, I might have to use one of the above packages. But I think that's not the most effective way in my case.

edit: This seems to be a better MWE, but I am still not sure which environment is best in this case and which kind of columns are.

\documentclass[a4paper, 12pt, headsepline, smallheadings]{scrreprt}
\usepackage{tabularx}
\begin{document}
\begin{tabular}{p{4cm}p{12cm}}
US  & United States \\
EU & European Union \\
Gvmt & Government \\
\end{tabular}
\end{document}

I have found this: Creating abbreviations list with manual entries but it does not add cdots and it doesn't work for longer abbreviations because the distance b/w the columns is too small. I'd like to have control over the distance.

Thanks.

  • I would use the tabbing environment. – Marco Daniel Dec 12 '13 at 20:12
  • @MarcoDaniel Hey, could you elaborate a little bit? I found the environment before, but I didn't see any options to change the length of the distance between the columns, or to print cdots on the distance. – TomM Dec 12 '13 at 20:22
  • @MarcoDaniel I have tested dotfill in tabbing. It doesn't seem to work the usual way. – TomM Dec 12 '13 at 21:42
20

Make your own "abbreviations" environment. For example

\documentclass{article}
\newcommand{\abbrlabel}[1]{\makebox[3cm][l]{\textbf{#1}\ \dotfill}}
\newenvironment{abbreviations}{\begin{list}{}{\renewcommand{\makelabel}{\abbrlabel}}}{\end{list}}
\begin{document}
\begin{abbreviations}
\item[US] United States
\item[EU] European Union
\item[Gvmt] Government
\end{abbreviations}
\end{document}

Adjust the size of the makebox to suit your entries. If you don't like the dots, then remove the \dotfill command.

enter image description here

If you want to make this look more like the table of contents, then we have to make another slightly more complicated command to do the dots instead of plain TeX's \dotfill.

\makeatletter
\newcommand{\tocfill}{\cleaders\hbox{$\m@th \mkern\@dotsep mu . \mkern\@dotsep mu$}\hfill}
\makeatother
\newcommand{\abbrlabel}[1]{\makebox[3cm][l]{\textbf{#1}\ \tocfill}}

This uses the LaTeX parameter \@dotsep which controls the spacing of the dots in the table of contents. With \abbrlabel defined with \tocfill we get this.

enter image description here

To control the vertical spacing, we need to adjust the standard list dimension \itemsep which is added to the skip between each item. We can set this to what ever we want, as part of the environment definition. With these extra bells and whistles, the example looks like this:

\documentclass{article}
\makeatletter
\newcommand{\tocfill}{\cleaders\hbox{$\m@th \mkern\@dotsep mu . \mkern\@dotsep mu$}\hfill}
\makeatother
\newcommand{\abbrlabel}[1]{\makebox[3cm][l]{\textbf{#1}\ \tocfill}}
\newenvironment{abbreviations}{\begin{list}{}{\renewcommand{\makelabel}{\abbrlabel}%
                                              \setlength{\itemsep}{0pt}}}{\end{list}}
\begin{document}
\begin{abbreviations}
\item[US] United States
\item[EU] European Union
\item[Gvmt] Government
\end{abbreviations}
\end{document}

and produces this slightly tighter list.

enter image description here

The only remaining problems are to make sure the new environment fits into its surroundings neatly and to cope with unusually long explanations of abbreviations. This requires some extra fiddling with the margins of the list environment, like this.

\documentclass{article}
\usepackage{calc}
\usepackage{lipsum}
\makeatletter
\newcommand{\tocfill}{\cleaders\hbox{$\m@th \mkern\@dotsep mu . \mkern\@dotsep mu$}\hfill}
\makeatother
\newcommand{\abbrlabel}[1]{\makebox[3cm][l]{\textbf{#1}\ \tocfill}}
\newenvironment{abbreviations}{\begin{list}{}{\renewcommand{\makelabel}{\abbrlabel}%
        \setlength{\labelwidth}{3cm}\setlength{\leftmargin}{\labelwidth+\labelsep}%
                                              \setlength{\itemsep}{0pt}}}{\end{list}}
\begin{document}
\noindent\lipsum[1]
\begin{abbreviations}
\item[US] United States
\item[EU] European Union
\item[Gvmt] Government. \lipsum[2]
\end{abbreviations} 
\lipsum[3]
\end{document}

Here we've added the lipsum package for the filler text, and calc to allow us to use the + sign in setting the \leftmargin length.

enter image description here

For customizations like this, the Latex Companion is an indispensable reference.

| improve this answer | |
  • This is very good and close to perfect :) Only 1 thing: The dots on the left are much closer to the letters than the dots on the right. \hspace{3.5pt} before \dotfill seems to be a little adjustment which works. One more thing: Is there any way to adjust the spacing? (right now it seems to be doublespacing or at least oneandahalf). – TomM Dec 12 '13 at 23:24
  • Cannot edit my old post anymore. Just wanted to add that the spacing is unfortunately not correct. I need the same spacing as the toc, or in other words no list-specific spacing. – TomM Dec 12 '13 at 23:51
  • 1
    Sure, yes, we can redefine \dotfill or use a different macro to match the TOC. I'll update the answer with some different options and spacing details. – Thruston Dec 13 '13 at 16:10
3

Another solution, that answers Column alignment with horizontal dots.

It is based on the enumitem and etoolbox packages:

\documentclass[12pt, a4paper, oneside, fleqn]{report}
\usepackage[utf8]{inputenc}

\usepackage{enumitem}

\usepackage[showframe, top=2.5cm, left=3.5cm, bottom=2.5cm, right=2.5cm, includehead]{geometry}
\usepackage{etoolbox}

\newlist{mydescription}{description}{1}
\setlist[mydescription, 1]{style = standard, labelwidth=2.5cm, leftmargin = 2.5cm, labelsep = 0pt, itemsep = 1pt}%
\AtBeginEnvironment{mydescription}{%
\let\olditem\item
\renewcommand\item[1][]{\olditem[#1~\dotfill\,]}
}%

\begin{document}
Text text text
\begin{mydescription}
  \item[$l_i$] vzdálenost od manometru kústí vté trubice
  \item[$r_1$] poloměr $ i $-té trubice
  \item[$ Δ p_i$] úbitek statického tleku mezi manometrem a ústim trubice
\end{mydescription}

\end{document} 

enter image description here

| improve this answer | |
1

A minimalist solution. If you want more dots put more \dots inside the @{$\dots\dots$} .

\documentclass[a4paper, 12pt]{scrreprt}
\begin{document}
\begin{tabular}{l@{$\dots\dots$}p{12cm}}
US\dotfill  & United States \\
EU\dotfill & European Union \\
Gvmt\dotfill & Government \\
\end{tabular}
\end{document}

enter image description here

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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