[Tex/LaTex] Standardise distance between abbreviations and definitions – acro

acro

I am making a list of abbreviations for a thesis, that will have multiple categories (and probably around 100 abbreviations in total). I want to subgroup these into various classes.

The acro package allows this, and allows me to standardise the distance between the start of the first letter and definition, using the \acsetup{list-style=tabular} command. However, if I want multiple lists of abbreviations (see MWE below), the distance changes between tables. Is there a way of standardising this, so that I can set this manually, so that it is the same for both lists?

The MWE below gives me two lists (good), but the distance differs depending on the length of acronyms in each of the lists (bad).

I am keen to continue using acro as it other options that I find very useful.

MWE:

\documentclass{article}

\usepackage{acro}
\usepackage{relsize}
\usepackage[hidelinks]{hyperref}

\DeclareAcronym{SALSAS}{
    short = SALSAS ,
    long  = some are long some are short ,
    class = long
}
\DeclareAcronym{HP}{
    short = HP ,
    long  = help putting ,
    class = long
}


\DeclareAcronym{S}
{   short = S , 
    long = short ,
    class = short}

\DeclareAcronym{C}
{   short = C , 
    long = command ,
    class = short}



\acsetup{list-heading=subsection*} %Means that the acronyms lists are classed as a subsection
\acsetup{list-style=tabular}


\setlength{\tabcolsep}{10pt}


\begin{document}


    \section*{Acronyms}


    \printacronyms[include-classes=long,name={Long}]

    \printacronyms[include-classes=short,name={Short}]




Acronyms are useful: \ac{SALSAS}. The \ac{S} ones are my favourite. Any \ac{HP} tables in the right \acp{C} would be gratefully received. 



\end{document}

Different widths

Best Answer

Here's a hack that changes the template for the tabular; I wasn't able to find a better solution, as the column types are hardcoded.

I'd say that an automatic solution is out of question, because it would need measuring all acronyms and set the width for the column. Maybe the package author can think to something better.

Adjust the length (now 2cm) where %<--- appears

\documentclass{article}

\usepackage{acro}
\usepackage{relsize}
\usepackage[hidelinks]{hyperref}

\DeclareAcronym{SALSAS}{
    short = SALSAS ,
    long  = some are long some are short ,
    class = long
}
\DeclareAcronym{HP}{
    short = HP ,
    long  = help putting ,
    class = long
}


\DeclareAcronym{S}
{   short = S , 
    long = short ,
    class = short}

\DeclareAcronym{C}
{   short = C , 
    long = command ,
    class = short}

\acsetup{list-heading=subsection*} %Means that the acronyms lists are classed as a subsection
\acsetup{list-style=tabular}

\ExplSyntaxOn
\DeclareTemplateInterface {acro-list} {table} {3}
  {
    table       : tokenlist = longtable         ,
    table-spec  : tokenlist = p{2cm}p{\l__acro_table_width_dim} ,%<---
    foreign-sep : tokenlist = { ~ }
  }
\DeclareInstance { acro-list } { tabular }
  { table }
  { table = tabular }
\ExplSyntaxOff

%\setlength{\tabcolsep}{10pt}


\begin{document}


    \section*{Acronyms}


    \printacronyms[include-classes=long,name={Long}]

    \printacronyms[include-classes=short,name={Short}]

Acronyms are useful: \ac{SALSAS}. The \ac{S} ones are my favourite. Any \ac{HP} tables in the right \acp{C} would be gratefully received. 

\end{document}

enter image description here


Update

With a newer version of acro it's possible to act on the list without hacks.

\documentclass{article}

\usepackage{acro}

\DeclareAcronym{SALSAS}{
    short = SALSAS ,
    long  = some are long some are short ,
    class = long
}
\DeclareAcronym{HP}{
    short = HP ,
    long  = help putting ,
    class = long
}

\DeclareAcronym{S}
{   short = S , 
    long = short ,
    class = short}

\DeclareAcronym{C}
{   short = C , 
    long = command ,
    class = short}

\DeclareAcroListStyle{mytabular}{table}{
  table=tabular,
  table-spec=@{}p{2cm}p{\dimexpr\textwidth-2cm-2\tabcolsep}@{},
}

\acsetup{list-heading=subsection*} %Means that the acronyms lists are classed as a subsection
\acsetup{list-style=mytabular}

\begin{document}

\section*{Acronyms}

\printacronyms[include-classes=long,name={Long}]

\printacronyms[include-classes=short,name={Short}]

Acronyms are useful: \ac{SALSAS}. The \ac{S} ones are my favourite. Any \ac{HP} tables in the right 
\acp{C} would be gratefully received.

\end{document}

enter image description here

Related Question