Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to \printacronyms to write the output to a file #119

Closed
cgnieder opened this issue Jan 18, 2019 · 6 comments
Closed

Add option to \printacronyms to write the output to a file #119

cgnieder opened this issue Jan 18, 2019 · 6 comments
Labels
enhancement New feature or request

Comments

@cgnieder
Copy link
Owner

Original report by Joe Sapp (Bitbucket: sappj, ).


It would be handy in some situations to have the output of \printacronyms write to a LaTeX file. For example, some publishers want the list embedded in the file. The original document could be used to generate the list and can be included with the version sent off to the publisher. Something like pgfplotstable's outfile option:

/pgfplots/table/outfile={file name} (initially empty)

Writes the generated tabular code into file name. It can then be used with \input{file name},
PgfplotsTable is no longer required since it contains a completely normal tabular.

@cgnieder
Copy link
Owner Author

Original comment by Clemens Niederberger (Bitbucket: cgnieder, GitHub: cgnieder).


This sounds like an interesting idea.

@cgnieder
Copy link
Owner Author

Original comment by Clemens Niederberger (Bitbucket: cgnieder, GitHub: cgnieder).


It is rather easy to implement something which writes a file containing lines like

\begin {description}
  \acro_print_list_entry:nnnn
    {\acro_list_entry:nn {short}{one}}
    {\acro_list_entry:nn {long}{one}}
    {\acro_list_entry:nn {extra}{one}}
    {\acro_list_entry:nn {page}{one}}
  \acro_print_list_entry:nnnn
    {\acro_list_entry:nn {short}{two}}
    {\acro_list_entry:nn {long}{two}}
    {\acro_list_entry:nn {extra}{two}}
    {\acro_list_entry:nn {page}{two}}
\end {description}

I’m not sure this is the desired outcome, is it?

@cgnieder
Copy link
Owner Author

Original comment by Joe Sapp (Bitbucket: sappj, ).


The output file couldn’t depend on acro, so any macros would need to be defined in the file. So what you described would work as long as \acro_print_list_entry and \acro_list_entry are defined in the file (and can be included multiple times if multiple acronym lists are included in the document). I think a better alternative would be to expand any formatting so that the output file is something like

\section*{Acronyms}% % Assuming we didn't change list-heading or list-name
\begin {description}%
  \item [cd] Compact Disc%
  \item [id] identification string%
\end {description}%

@cgnieder
Copy link
Owner Author

Original comment by Clemens Niederberger (Bitbucket: cgnieder, GitHub: cgnieder).


That’s what I thought…

@cgnieder
Copy link
Owner Author

cgnieder commented Jan 5, 2020

Original comment by Clemens Niederberger (Bitbucket: cgnieder, GitHub: cgnieder).


Removing version: 2.8 (automated comment)

@cgnieder cgnieder added minor enhancement New feature or request and removed minor labels Mar 8, 2020
@cgnieder
Copy link
Owner Author

Version 3.0 makes this possible, although one can't expect too fancy lists here with it. This code

\documentclass{article}
\usepackage[enable-debug]{expl3}

\usepackage[version=3]{acro}

\makeatletter
\NewAcroTemplate[list]{external}{%
  \if@filesw
    \newwrite\acro@list
    \immediate\openout\acro@list\jobname.ac\relax
    \immediate\write\acro@list{\string\begin{description}}
    \let\item\relax
    \acronymsmapF{%
      \immediate\write\acro@list{%
        \space\space
        \item[\acrofield{##1}{short}]
        \acrofield{##1}{long}%
        \acrofieldifTF{##1}{extra}{ (\acrofield{##1}{extra})}{}%
      }%
    }{\immediate\write\acro@list{\item}\AcroRerun{list}}%
    \immediate\write\acro@list{\string\end{description}}
    \immediate\closeout\acro@list
  \fi
}
\makeatother

\DeclareAcronym{ny}{
  short = NY ,
  long = New York ,
}

\DeclareAcronym{la}{
  short = LA ,
  long = Los Angeles ,
  extra = City of Angels
}

\DeclareAcronym{dc}{
  short = D.C. ,
  long = Washington D.C.
}

\begin{document}

\acuseall
\printacronyms[template=external]
\null

\end{document}

produces a file with these contents:

\begin{description}
  \item [D.C.] Washington D.C.
  \item [LA] Los Angeles (City of Angels)
  \item [NY] New York
\end{description}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant