Wednesday, July 18, 2007

Protype for simplifying changing cleveref defaults

UPDATE: I have created crefntheoremdefaults.tex, which does this same stuff to the ntheorem package. You have to be sure to include the crefdefaults.tex file first. The files crefntheoremdefault_constants.tex and crefntheoremdefault_formats.tex play a similar role as the analogous ones below.

I think the package cleveref is great. In fact, I think it has much of what has been missing from LaTeX for a long time. See its documentation for more information about the package.

My only gripe about cleveref is that it is tedious to change something like all of the default "eq." and "eqs." to "Eq." and "Eqs.", respectively. So I put together these scripts as a kind of proof of concept (they also setup cleveref to handle table references, something that is not done by default at the moment):

The first script, crefdefaults.tex, is simply crefdefault_constants.tex concatenated with crefdefault_formats.tex. Therefore,
\input{crefdefaults.tex}
is equivalent to
\input{crefdefault_constants.tex}
\input{crefdefault_formats.tex}
However, if the poorman option is used and the corresponding sed script is applied, the resulting file will need to have the content of crefdefault_formats.tex removed; crefdefault_constants.tex should not be removed. In other words, if you are planning on using poorman, use the 2-line include and comment the crefdefault_formats.tex line out of the script that results from the sed script.

What's the outcome of this? I can now do
\renewcommand{\crefenumilabelformat}[3]{\textup{(#2#1#3)}}
in order to change every item reference so that it is surrounded by upright round braces. Additionally, changing "eq." to "Eq." and "eqs." to "Eqs." is as simple as it was in hyperref (for use with \autoref); that is, it is these two lines:
\renewcommand{\crefequationname}{Eq.}
\renewcommand{\crefpluralequationname}{Eqs.}
Unfortunately, the output of the poorman sed filter is a little messy. However, if these are someday integrated into cleveref, that could be fixed. There are other shortcuts built into crefdefaults.tex as well. It probably requires documentation, but it's just a prototype for now.

Good idea? Bad?

No comments: