1

With version 4 of arara, I was able to typeset two versions of a document nicely by inputting different files with different definitions according to arara rules.

Unfortunately, this has stopped working with arara 5.0. I know that in the yaml rule, I need to replace file with reference. I also experimented with using getCommand and return getCommand, however to no success (not that I'm experienced in programming).

In the following, I tried to give a MWE of both my .tex file as well as of the yaml rule. Any help is appreciated!

Latex Document:

% arara: pdfversions: {rules: _lv}
% arara: pdfversions: {rules: _sv}
\ifdefined\Version
\else
    \def\Version{_lv}
\fi
%
\documentclass[a4paper, 11pt]{article}
\usepackage[english, ngerman]{babel}
\usepackage{xcolor}
\input{\Version} %calls file _lv oder _ls, depending on arara rule
%file _lv contains (among others): \newenvironment*{LV}{\LARGE\color{red}}{\hspace{0.25cm}\normalsize}
%file _sv contains (among others): \newenvironment*{LV}{\LARGE\color{white}}{\hspace{0.25cm}\normalsize}
%
\begin{document}
\begin{LV}
test
\end{LV}
\end{document}

The idea of the arara rule is that that it defines either _lv or _sv in the beginning, thus loads the file _ls or _sv, then typesets the file according to the definitions on the corresponding file, creates a PDF with the ending _LV or _SV and finally opens the PDF.

YAML file with rules:

!config
# PDFLaTeX rule for arara to return 2 PDF Files, a teacher and a student version
# author: based on code from Chris Hughes
# requires arara 4.0+
# % arara: pdfversions
# % arara: pdfversions: {rules: _lv}
# % arara: pdfversions: {rules: _sv}
identifier: pdfversions
name: PDFVersions
commands:
- command: <arara> pdflatex "\def\Version{@{rules}}\input{@{file}}"
- command: <arara> @{ isWindows( "cmd /c move", "mv" ) } @{getBasename(file)}.pdf @{getBasename(file)}@{rules.toUpperCase()}.pdf
- command: <arara> open @{getBasename(file)}@{rules.toUpperCase()}.pdf
arguments:
- identifier: rules
  flag: <arara> @{parameters.rules}
  default: _lv
2

As you mentioned: from arara v5 on, you cannot access file anymore. reference is there to help because it is a properly typed file object. There has been a question about this major change in arara v5.

Please note, that the <arara> shorthand syntax is deprecated (will be removed in v6). Support for returning string commands has been removed in favor of the much cleaner getCommand approach.

All of the above changes are also detailed in the changelog.

The following is untested:

!config
# PDFLaTeX rule for arara to return 2 PDF Files,
# a teacher and a student version
# author: based on code from Chris Hughes
# requires arara 4.0+
# % arara: pdfversions
# % arara: pdfversions: {rules: _lv}
# % arara: pdfversions: {rules: _sv}
identifier: pdfversions
name: PDFVersions
commands:
- command: >
    @{
      return getCommand('pdflatex', '\\def\\Version{' + rules + '}\\input{'
                        + reference.getName() + '}');
    }
- command: >
    @{
      output = getBasename(reference.getName()) + rules.toUpperCase() + '.pdf';
      return getCommand(isWindows([ 'cmd', '/c', 'move' ], 'mv'),
             reference.getName(), output);
    }
- command: >
    @{
      return getCommand('open', getBasename(reference.getName()) +
                        rules.toUpperCase() + '.pdf');
    }
arguments:
- identifier: rules
  flag: >
    @{
      return parameters.rules;
    }
  default: _lv
| improve this answer | |
  • Wow, thanks very much! In the second command, I had to change the reference.getName(), since like this, the .tex file was moved / deleted. I changed it to - command: > @{ output = getBasename(reference.getName()) + rules.toUpperCase() + '.pdf'; input = getBasename(reference.getName()) + '.pdf'; return getCommand('cp', input, output); } which works like a charm. Thanks again! – Manuel Apr 15 at 15:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.