5

I wanted to know what will be the best way to get my list of abbreviations to show up like:

enter image description here

Here is some code modified from this post in order to generate the list of abbreviations:

\documentclass{book}
\usepackage{acro}

% probably a good idea for the nomenclature entries:
\acsetup{first-style=short}

 %class `abbrev': abbreviations:
\DeclareAcronym{PLL}{
  short = PLL ,
  long  = Phase Locked Loop ,
  class = abbrev
}

\DeclareAcronym{HP}{
  short = HP ,
  long  = High Port ,
  class = abbrev
}

\DeclareAcronym{LP}{
  short = LP ,
  long  = Low Port ,
  class = abbrev
}


\begin{document}

\ac{HP}, \ac{PLL} and \ac{LP} are abbreviations whereas
are part of the nomenclature

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


\end{document}

Thanks for your help!

Joe
  • 9,080

1 Answers1

5

In order to get an acronym list similar to the one in the picture you need at least v2.6e (2016/09/04) of acro.

You need to declare a new instance of the acro-list object and provide the template code for the new instance. Unfortunately this still requires use of some internal variables but their usage should be safe enough.

With the help of colortbl and tabu the rest is just adding the “fancy” stuff:

enter image description here

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{acro,tabu,longtable,xcolor,colortbl}

\ExplSyntaxOn

\tl_new:N \l__acro_fancy_color_tl

% a new interface for the acro-list:
\DeclareTemplateInterface {acro-list} {fancy-table} {2}
  {
    foreign-sep : tokenlist = {~} ,
    before      : tokenlist = ,
    after       : tokenlist = ,
    color       : tokenlist = red!20
  }

% now the code for the new interface -- similar to existing ones but adding
% the `fancy' stuff:
\DeclareTemplateCode {acro-list} {fancy-table} {2}
  {
    foreign-sep = \l__acro_foreign_sep_tl ,
    before      = \l__acro_list_before_tl ,
    after       = \l__acro_list_after_tl ,
    color       = \l__acro_fancy_color_tl
  }
  {
    \AssignTemplateKeys
    \acro_activate_hyperref_support:
    \cs_set_protected:Npn \acro_print_list_entry:nnnn ##1##2##3##4
      {
        ##1 \strut &
        \cellcolor {\l__acro_fancy_color_tl} \strut ##3 ##2 ##4 \strut \\
        \strut & \\
      }
    \acro_build_list_entries:Nnn \l__acro_list_entries_tl {#1} {#2}
    \tabulinesep = 1.2pt
    \extrarowsep = 1.2pt
    \tabulinestyle { 1.2pt \l__acro_fancy_color_tl }
    \use:x
      {
        \exp_not:V \l__acro_list_before_tl
        \exp_not:n
          {
            \begin {longtabu} to \linewidth {X[1,r]|X[4]|}
              \multicolumn {1} {r} {\bfseries\itshape Abbreviation} &
              \multicolumn {1} {l} {\bfseries Explanation} \\
              \tabucline-
          }
        \exp_not:V \l__acro_list_entries_tl
        \exp_not:N \end {longtabu}
        \exp_not:V \l__acro_list_after_tl
      }
  }

% at last we need to provide at least one style using the instance:
\DeclareAcroListStyle {joe} {fancy-table} { color = blue!20 }
\ExplSyntaxOff

\acsetup{
  first-style = short ,
  list-style = joe , % we use the newly defined style
  list-short-format = \itshape
}

\DeclareAcronym{PLL}{
  short = PLL ,
  long  = Phase Locked Loop
}

\DeclareAcronym{HP}{
  short = HP ,
  long  = High Port
}

\DeclareAcronym{LP}{
  short = LP ,
  long  = Low Port
}

\renewcommand\familydefault{\sfdefault}% I assumed this from the picture

\begin{document}

\ac{HP}, \ac{PLL} and \ac{LP} are abbreviations

\printacronyms

\end{document}
cgnieder
  • 66,645
  • THANKS for your response. For some reason, I get the error, \template code > acro-list/fancy-table ...ies:Nnn \l__acro_list_entries_t1 {... Can you tell me how to fix this? – Joe Sep 07 '16 at 16:49
  • 1
    Do you have an up to date tex distribution? – cgnieder Sep 07 '16 at 17:31