Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

436 lines (428 sloc) 14.648 kb
% \iffalse
%
%<*internal>
\begingroup
%</internal>
%<*batchfile>
\input docstrip.tex
\keepsilent
\preamble
The Acroterm package
Copyright (C) 2010 by Jakob Voss
Distributable under the LaTeX Project Public License,
version 1.3c or higher (your choice). The latest version of
this license is at: http://www.latex-project.org/lppl.txt
This work is "maintained" (as per LPPL maintenance status)
by Jakob Voss.
This work consists of the file acroterm.dtx
and the derived files acroterm.sty,
acroterm.ins, and
acroterm.pdf.
\endpreamble
\askforoverwritefalse
\generate{\file{acroterm.sty}{\from{acroterm.dtx}{package}}}
%</batchfile>
%<batchfile>\endbatchfile
%<*internal>
\generate{\file{acroterm.ins}{\from{acroterm.dtx}{batchfile}}}
\def\tmpa{plain}
\ifx\tmpa\fmtname\endgroup\expandafter\bye\fi
\endgroup
%</internal>
%
% \begin{macrocode}
%<*driver>
\ProvidesFile{acroterm.dtx}
%</driver>
%<package>\ProvidesPackage{acroterm}
%<*package>
[2011/01/28 v0.1c Manage and index acronyms and terms]
%</package>
% \end{macrocode}
%
%<*driver>
\documentclass{ltxdoc}
\usepackage{acroterm}
\usepackage[
pdfborder={0 0 0},colorlinks,
linkcolor=blue, citecolor=green, urlcolor=magenta
]{hyperref}
\newcommand*\pkg[1]{\texttt{#1}}
\setlength\parindent{0pt}
\begin{document}
\DocInput{\jobname.dtx}
\end{document}
%</driver>
%
% \fi
%
% \errorcontextlines=999
%
% \GetFileInfo{\jobname.sty}
%
% \title{The \pkg{\jobname} package}
% \author{Jakob Voss}
% \date{\filedate ~ \fileversion}
%
% \maketitle
% \tableofcontents
% \setlength\parskip{7pt}
%
% \section{Introduction}
%
% There are several packages to manage acronyms in \TeX. CTAN lists at least
% \pkg{acronym},\footnote{%
% \url{http://www.ctan.org/tex-archive/macros/latex/contrib/acronym/}}
% \pkg{acromake},\footnote{%
% \url{http://www.ctan.org/tex-archive/macros/latex/contrib/acromake/}},
% \pkg{glosstex},\footnote{%
% \url{http://www.ctan.org/tex-archive/support/glosstex/}} and
% \pkg{glossary}.\footnote{%
% \url{http://www.ctan.org/tex-archive/macros/latex/contrib/glossary/}}
% These packages let you define acronyms, that can be expanded automatically.
% But you rarely control when to expand, and defining acronyms can be annoying.
% The \pkg{\jobname} package lets you naturally use acronyms and technical
% terms in you document. You can mark up acronyms (|\acro|) and terms
% (|\term|) as such, to get them formatted consistently and to include
% them in an index. In addition you can connect acronyms and terms that
% belong together. You fully control, where a term is used in full form,
% and where it is used as acronym. Tracking the first ocurrence of a term
% is not the primary goal of this package, but may be implemented in a later
% version.
%
% The current version of this package is a developer version that still depends
% on the packages \pkg{splitidx} and \pkg{hyperref}. Please load \pkg{acroterm}
% between the two.
%
% A small example is included in this package in file |example.tex|.
%
% \newpage
% \section{Description}
%
% Essentially, this package provides four macros to mark terms, acronyms, and both:
%
% \begin{tabular}{lcl}
% |\acro{SNAFU}| & $\longrightarrow$ & \acro{SNAFU} \\
% |\term{Potrzebie}| & $\longrightarrow$ & \term{Potrzebie} \\
% |\tacro{Do it yourself}{DIY}| & $\longrightarrow$ & \tacro{Do it yourself}{DIY} \\
% |\aterm{DIY}{Do it yourself}| & $\longrightarrow$ & \aterm{DIY}{Do it yourself} \\
% \end{tabular}
%
% After definition of an acronym like above, you can also use:
%
% ~~|\acroexpand{DIY}|~~$\longrightarrow$~~Do it yourself
%
% The macros |\term| and |\acro| simply set some text as term or
% as acronym. |\tacro| and |\aterm| mark a term together with its
% acronym or vice versa. In all cases, terms and acronyms are put
% into a special index.
%
% Each command has an emphasizing variant that starts with an uppercase letter:
%
% \begin{tabular}{lcl}
% |\Acro{SNAFU}| & $\longrightarrow$ & \Acro{SNAFU} \\
% |\Term{Potrzebie}| & $\longrightarrow$ & \Term{Potrzebie} \\
% |\Tacro{Do it yourself}{DIY}| & $\longrightarrow$ & \Tacro{Do it yourself}{DIY} \\
% |\Aterm{DIY}{Do it yourself}| & $\longrightarrow$ & \Aterm{DIY}{Do it yourself} \\
% \end{tabular}
%
% Layout can be controlled globally by redefining various |\...style| macros,
% which can also be used seperately. A usual setting is:
%%
% \begin{tabular}{l}
% |\usepackage{relsize}| \\
% |\renewcommand{\acrostyle}[1]{\textsc{\smaller #1}}| \\
% |\renewcommand{\Acrostyle}[1]{\textsc{#1}}| \\
% |\renewcommand{\Termstyle}[1]{\textbf{#1}}| \\
% \end{tabular}
%%
% By default, \emph{emphasized} terms and acronyms show up differently also in
% the generated index. To prevent that page numbers show up twice (once normal
% and once emphasized) you may need to filter the |.idx| file. To index a term
% or acronym, without printing it in the text, use any of the starred macros
% |\term*|, |\Term*|, |\acro*|, and |\Acro*|.
%
% |\term| and |\tacro| support an optional parameter for indexing.
% With
%
% ~~|\term[Potrzebie System of Weights and Measures]{Potrzebie System}|
%
% the term `Potrzebie System of Weights and Measures' is included in the index
% but `\term[Potrzebie System of Weights and Measures]{Potrzebie System}`
% is printed in the text. In the same way
%
% ~~|\tacro[Gang of Four (Patterns)]{Gang of Four}{GoF}|
%
% prints `\tacro[Gang of Four (Patterns)]{Gang of Four}{GoF}` but indexes
% `Gang of Four (Patterns)'.
%
% \newpage
% \section{Implementation}
%\iffalse
%<*package>
%\fi
% The current version of \pkg{\jobname} depends on \pkg{splitidx} for index
% generation. This dependency may be removed in a future version.
%
% \begin{macrocode}
\RequirePackage{splitidx}[2009/02/18 v1.1a]
\RequirePackage{xifthen}[2009/03/17]
% \end{macrocode}
%
% \subsection*{Simple layout settings}
%
% The following commands are used to simply print acronyms and terms.
% They do not index but only format the arguments. You can redefine them
% to change layout of acronyms and terms. The uppercase variant is used
% for emphasizing.
%
% \begin{macro}{\acrostyle}
% \begin{macro}{\Acrostyle}
% Print an acronym normal (|\acrostyle|), or emphasized (|\Acrostyle|).
% The argument is \marg{acronym}. An normal acronym is printed as lowercase
% small caps, such as \acrostyle{This}. An emphasized acronym is printed
% uppercase italics, such as \Acrostyle{This}.
% \begin{macrocode}
\newcommand{\acrostyle}[1]{\textsc{\lowercase{#1}}}
\newcommand{\Acrostyle}[1]{\textit{\uppercase{#1}}}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\termstyle}
% \begin{macro}{\Termstyle}
% Print a term normal (|\termstyle|), or emphasized (|\Termstyle|).
% The argument is \marg{term}. A normal term is printed without modification.
% An emphasized term is printed in italics, such as \Termstyle{this}.
% \begin{macrocode}
\newcommand{\termstyle}[1]{#1}
\newcommand{\Termstyle}[1]{\textit{#1}}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\tacrostyle}
% \begin{macro}{\Tacrostyle}
% Print a term and its acronym normal (|\tacrostyle|), or emphasized
% (|\Tacrostyle|). The arguments are \marg{term}\marg{acronym}. In
% emphasized form, only the term is emphasized, so
% |\Tacrostyle{Knockout}{KO}| prints \Tacrostyle{Knockout}{KO}.
% \begin{macrocode}
\newcommand{\tacrostyle}[2]{\termstyle{#1} (\acrostyle{#2})}
\newcommand{\Tacrostyle}[2]{\Termstyle{#1} (\acrostyle{#2})}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\atermstyle}
% \begin{macro}{\Atermstyle}
% Print an acronym and its term normal (|\atermstyle|), or emphasized
% (|\Atermstyle|). The arguments are \marg{term}\marg{acronym}. In
% emphasized form, only the acronym is emphasized, so
% |\Atermstyle{KO}{Knockout}| prints \Atermstyle{KO}{Knockout}.
% \begin{macrocode}
\newcommand{\atermstyle}[2]{\acrostyle{#1} (\termstyle{#2})}
\newcommand{\Atermstyle}[2]{\acrostyle{#1} (\termstyle{#2})}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\acroindexstyle}
% Print an acronym how it should show up as index entry. The argument
% is \marg{acronym}. If there is no expanded term for a given acronym,
% this is equal to |\acrostyle|. Otherwise |\acroindexstyle{KO}| prints
% \acrostyle{KO} --- Knockout.
% \begin{macrocode}
\newcommand{\acroindexstyle}[1]{\acrostyle{#1}\acroexpand[ --- ]{#1}}
% \end{macrocode}
% \end{macro}
%
% \subsection*{Internal macros}
%
% \begin{macro}{\provideacronym}
% Connects an acronym (that must only contain letters) with a term.
% No output or index entry is generated. In most cases you do not
% need to explicitly use this macro. Arguments are \marg{acronmy}\marg{term}.
% \begin{macrocode}
\newcommand{\provideacronym}[2]{% TODO: detect redefinitions
\expandafter\providecommand\expandafter{%
\csname acronymlong#1\endcsname}{#2}%
}
% \end{macrocode}
% \end{macro}
%
% \subsection*{Index generation}
%
% \begin{macro}{\acrotermbfhp}
% The following hack is required hack to mix hyperref and formatted page numbers.
% The command is internal although it does not contain an |@| character.
% \begin{macrocode}
\newcommand{\acrotermbfhp}[1]{\textbf{\hyperpage{#1}}}
% \end{macrocode}
% \end{macro}
%
% And some code for index generation (also to be fixed).
%
% \begin{macrocode}
\newcommand{\acro@define}[2]{% #1: long term, #2: acronym
\sindex[idx]{#1|see{\acrostyle{#2}}}% TODO: acronyms in general index?
\@ifundefined{acronymlong#2}{%
\provideacronym{#2}{#1}}{}%
\sindex[acronym]{#2@\acroindexstyle{#2}|acrotermbfhp}%
}
% \end{macrocode}
% \begin{macro}{\acroexpand}
% print the expanded form (that is the term) of an acronym, if defined.
% The optional first parameter is prepended only on success.
% \begin{macrocode}
\newcommand{\acroexpand}[2][]{%
\@ifundefined{acronymlong#2}{}{%
#1\csname acronymlong#2\endcsname}%
}
% \end{macrocode}
% \end{macro}
%
% \subsection*{Main macros}
%
% \begin{macro}{\term}
% \begin{macro}{\term*}
% Marks a term in normal form. The arguments are \oarg{index term}\marg{term}.
% The starred version does not print anything, but only indexes the term.
% \begin{macrocode}
\def\term{\@ifstar\term@index\term@show}
\newcommand{\term@index}[2][]{%
\ifthenelse{\isempty{#1}}%
{\sindex[idx]{#2}}{\sindex[idx]{#1}}}
\newcommand{\term@show}[2][]{%
\term@index[#1]{#2}\termstyle{#2}}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\Term}
% \begin{macro}{\Term*}
% Marks a term in emphasized form. The arguments are
% \oarg{index term}\marg{term}. The starred version does not print
% anything, but only indexes the term.
% \begin{macrocode}
\def\Term{\@ifstar\Term@index\Term@show}
\newcommand{\Term@index}[2][]{%
\ifthenelse{\isempty{#1}}%
{\sindex[idx]{#2|acrotermbfhp}}%
{\sindex[idx]{#1|acrotermbfhp}}}
\newcommand{\Term@show}[2][]{%
\Term@index[#1]{#2}\Termstyle{#2}}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\acro}
% \begin{macro}{\acro*}
% Marks an acronym in normal form. The argument is \marg{acronym}.
% The starred version does not print anything, but only indexes the acronym.
% \begin{macrocode}
\def\acro{\@ifstar\acro@index\acro@show}
\newcommand{\acro@index}[1]{%
{\sindex[acronym]{#1@\acroindexstyle{#1}}}}
\newcommand{\acro@show}[1]{%
\acrostyle{#1}\acro@index{#1}}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\Acro}
% \begin{macro}{\Acro*}
% Marks an acronym in emphasized form. The argument is \marg{acronym}.
% The starred version does not print anything, but only indexes the acronym.
% \begin{macrocode}
\def\Acro{\@ifstar\Acro@index\Acro@show}
\newcommand{\Acro@index}[1]{%
{\sindex[acronym]{#1@\acroindexstyle{#1}}}}
\newcommand{\Acro@show}[1]{%
\Acrostyle{#1}\Acro@index{#1}}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\tacro}
% Marks a term and its acronym in normal form.\\
% The arguments are \oarg{index term}\marg{term}\marg{acronym}.
% \begin{macrocode}
\newcommand{\tacro}[3][]{%
\ifthenelse{\isempty{#1}}%
{\acro@define{#2}{#3}}{\acro@define{#1}{#3}}% TODO: not define?
\tacrostyle{#2}{#3}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\Tacro}
% Marks a term emphasized and its acronym.\\
% The arguments are \oarg{index term}\marg{term}\marg{acronym}.
% \begin{macrocode}
\newcommand{\Tacro}[3][]{%
\ifthenelse{\isempty{#1}}%
{\acro@define{#2}{#3}}{\acro@define{#1}{#3}}%
\Tacrostyle{#2}{#3}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\aterm}
% Marks an acronym and its term in normal form.
% The arguments are \marg{acronym}\marg{term}.
% \begin{macrocode}
\newcommand{\aterm}[2]{%
\acro@define{#2}{#1}% TODO: not define but only use?
\atermstyle{#1}{#2}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\Aterm}
% Marks an emphasized acronym and its term.\\
% The arguments are \marg{acronym}\marg{term}.
% \begin{macrocode}
\newcommand{\Aterm}[2]{%
\acro@define{#2}{#1}%
\Atermstyle{#1}{#2}}
% \end{macrocode}
% \end{macro}
%
% \subsection*{Bugs and missing features}
% Index generation may need to be fixed. We also want to discover multiple
% definitions of an acronom with different terms. Should terms, that
% are used without acronym, occurr in the acronym index?
%
% We can have (a) a single index of terms and acronyms
% (a.1) with or (a.2) without \textit{see} references from terms to acronyms
% (b) an an additional list of acronyms (b.1) with or
% (b.2) without page numbers, and with (b.x) or without (b.y) acronyms without
% term (c) terms in one index and acronyms in another
% (c.1) with or (c.2) without \textit{see} references from terms to acronyms.
%
% Possible future package options:
% |splitidx|, |acroindex=...|, |termindex=...|,
% |requireterms|, |strictterms|.
%
% Version 1.0 sure needs to support other index generators.
%
% See the section on `Auxiliary macros for name indexing directives'
% in biblatex source code for hints on including macros in the index.
%
% The latest development version of this package can be found at:\\
% \url{https://github.com/nichtich/acroterm}.
%
%\iffalse
%</package>
%\fi
%
% \Finale
%
% \typeout{*************************************************************}
% \typeout{*}
% \typeout{* To finish the installation you have to move the following}
% \typeout{* file into a directory searched by LaTeX:}
% \typeout{*}
% \typeout{* \space\space\space acroterm.sty}
% \typeout{*}
% \typeout{*************************************************************}
%
\endinput
Jump to Line
Something went wrong with that request. Please try again.