6

Hi, Here is a sample code of my problem:

\documentclass[12pt,a4paper]{report}
\usepackage[labelfont=bf]{caption}
\usepackage{listings}
\usepackage{acro}


\DeclareAcronym{loT}{
short = IoT ,
long = Internet of Things ,
class = abbrev
}

\DeclareAcronym{dbms}{
short = DBMS ,
long = Database Management System ,
class = abbrev
}
\begin{document}

\acuseall
\printacronyms[include-classes=abbrev,name=Abbreviations]
\end{document}

I have an abbreviation list, the result is: enter image description here

As you can see, between the abbreviation and the spread word, the space is the same, but this leads to the un-align or not neat ...so what I want is like this:

enter image description here

Can anyone help me with this...thanks a lot

cgnieder
  • 66,645

3 Answers3

6

The easiest way to me seems to be to load enumitem and define a new list:

\usepackage{enumitem}
\newlength\myitemwidth

\setlength\myitemwidth{5em} % <<< choose what you need here \newlist{myacronymlist}{description}{1} \setlist[myacronymlist]{ labelindent = 0pt , labelsep = 0pt , leftmargin = \myitemwidth , labelwidth = \myitemwidth , itemindent = 0pt , format = \normalfont }

and then tell acro to use this list:

\usepackage{acro}
\DeclareAcroListStyle{myliststyle}{list}{
  list = myacronymlist
}
\acsetup{ list-style = myliststyle }

Versions prior to v2.2 use the deprecated option list-type:

\usepackage{acro}
\acsetup{ list-type = myacronymlist }

The complete example:

\documentclass{article}

\usepackage{enumitem} \newlength\myitemwidth

\setlength\myitemwidth{5em} % <<< choose what you need here \newlist{myacronymlist}{description}{1} \setlist[myacronymlist]{ labelindent = 0pt , labelsep = 0pt , leftmargin = \myitemwidth , labelwidth = \myitemwidth , itemindent = 0pt , format = \normalfont }

\usepackage{acro} \DeclareAcroListStyle{myliststyle}{list}{ list = myacronymlist } \acsetup{ list-style = myliststyle }

\DeclareAcronym{loT}{ short = IoT , long = Internet of Things , class = abbrev }

\DeclareAcronym{dbms}{ short = DBMS , long = Database Management System , class = abbrev }

\begin{document}

\acuseall \printacronyms[include-classes=abbrev,name=Abbreviations]

\end{document}

enter image description here


For version 3 of acro the fastest adaption of the above code would be

\usepackage[version=3]{acro}

\SetupAcroTemplate[list]{description}{% \let\description\myacronymlist \let\enddescription\endmyacronymlist }

otherwise using the same definitions as above. This changes the default list template. One could define a custom template which does the same:

\usepackage[version=3]{acro}

\NewAcroTemplate[list]{custom}{% \let\description\myacronymlist \let\enddescription\endmyacronymlist \UseAcroTemplate[list]{description}[0]% }

\acsetup{list/template=custom}

In order to run without warnings with version 3, class should be replaced by tag in the acronym definitions and include-classes should become include in the list setup:

\documentclass{article}

\usepackage{enumitem} \newlength\myitemwidth

\setlength\myitemwidth{5em} % <<< choose what you need here \newlist{myacronymlist}{description}{1} \setlist[myacronymlist]{ labelindent = 0pt , labelsep = 0pt , leftmargin = \myitemwidth , labelwidth = \myitemwidth , itemindent = 0pt , format = \normalfont }

\usepackage[version=3]{acro}

\SetupAcroTemplate[list]{description}{% \let\description\myacronymlist \let\enddescription\endmyacronymlist }

\DeclareAcronym{loT}{ short = IoT , long = Internet of Things , tag = abbrev }

\DeclareAcronym{dbms}{ short = DBMS , long = Database Management System , tag = abbrev }

\begin{document}

\acuseall \printacronyms[include=abbrev,name=Abbreviations]

\end{document}

cgnieder
  • 66,645
  • When this is applied, abbreviations are no longer bold. Is there a way to fix it? – Cem Kalyoncu Aug 17 '15 at 20:29
  • 1
    @CemKalyoncu that's of course because of the format = \normalfont line. Change that to your needs… – cgnieder Aug 17 '15 at 20:32
  • Ah, thank you, I thought it would affect the entire line. Those who wonder, the tag for bold font is \bfseries – Cem Kalyoncu Aug 17 '15 at 20:39
  • The described method doesn't have any effect on my list, whether I chose 5em or 100em. Also \normalfont vs. \bfseries doesn't make any difference. Do I have to delte a file or something to make it refresh? – nmy2015 Feb 04 '16 at 21:22
  • @nmy2015 I updated my answer – cgnieder Feb 05 '16 at 11:30
  • With the update of the acro packe to version 3 this does not longer work, because of major changes in the code. But you can use the fallback to load the package with the option "version=2", then this old code will still work. Just took me a while to figure that out... – jusaca Jun 27 '20 at 10:41
  • 1
    @jusaca I added a solution for version 3 – cgnieder Jun 27 '20 at 14:23
3

I introduce the leftitemize environment, that places its labels in a 2cm wide left-aligned box (in bold). The labels are aligned with the enclosing environment margin.

\documentclass{article}
\usepackage{enumitem}
\let\svitem\item%
\def\mybox#1{\makebox[2cm][l]{\bfseries#1}}
\newenvironment{leftitemize}
{\renewcommand\item[1][$\bullet$]{\svitem[\mybox{##1}]}%
  \begin{itemize}[leftmargin=\dimexpr2cm+\labelsep]}{\end{itemize}}
\begin{document}
\noindent Here is my left margin
\begin{leftitemize}
\item[FFT] Fast Fourier Transform
\item[GPRS] General Packet Radio Services xxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxx
\end{leftitemize}
\end{document}

enter image description here

  • I don't think this answers the question. Following the link in the question I very much suspect that the OP uses the acro package for generating the list of acronyms… – cgnieder Jul 02 '15 at 13:42
  • @clemens Thanks for the heads up. I'll wait for the OP to confirm that before deleting the answer. – Steven B. Segletes Jul 02 '15 at 13:43
  • @ Steven B. Segletes, Thanks for your help. This way works. Even it is not exactly what I am using, but it is really good to know one more method to do this. @ clemens. Yes, I will update a minimal working example soon, so happy to see so many problems solved in here – user2307344 Jul 02 '15 at 13:49
  • hi, @StevenB.Segletes , after I used your method, my text font all change to default font, I defined a different font before. Did you do anything to change the font? how can this happens? Thanks – user2307344 Jul 07 '15 at 08:39
  • @user2307344 I am not exactly sure why that would happen (it doesn't for me). However, the one place I change font is with \bfseries#1 inside of \mybox. A safer way would be \textbf{#1}, though I still don't see exactly why that would make a difference. But it is worth a try. – Steven B. Segletes Jul 07 '15 at 09:39
  • Hi @ Steven B. Segletes What does \textbf{#1} means? Is it possible we do not define any font here? Since I already define the entire document in the beginning. – user2307344 Jul 07 '15 at 10:00
  • @user2307344 \textbf{} says to put the braced text as bold, like in the abbreviations at the beginning of the \item. It is true that (outside of that) I don't set any fonts in my example. Thus, perhaps the issue is that when incorporating my code into your document, you are also failing to set the desired font, in contrast to the way you had previously done it. – Steven B. Segletes Jul 07 '15 at 10:08
  • 1
    @ Steven B. Segletes . got it solved...it turned out I added one line which tried to change the font...thanks a lot – user2307344 Jul 07 '15 at 10:44
1

This is now part of the acro package. The easiest solution now is to add

list-style = tabular ,

or

list-style = extra-tabular , % Akronymliste als Tabelle mit 4 Spalten

if you are using the extra key in your abbreviations, acronyms, and initialisms to

\acsetup{<key-value-list>}

as in

\documentclass[12pt,a4paper]{report}
\usepackage[labelfont=bf]{caption}
\usepackage{listings}
\usepackage{acro}

\acsetup{list-style = tabular}           % <-----------

\DeclareAcronym{loT}{
short = IoT ,
long = Internet of Things ,
class = abbrev
}

\DeclareAcronym{dbms}{
short = DBMS ,
long = Database Management System ,
class = abbrev
}
\begin{document}

\acuseall
\printacronyms[include-classes=abbrev,name=Abbreviations]
\end{document}

(I really like the command \acuseall. "I accuse AAALLLLLLL of you! Cursed be your offspring four generations down!")

thymaro
  • 1,507