2

Objective:

I want to compile the temporary.tex file containing PSTricks code twice. One with -jobname=Rotated and the other one with -jobname=Unrotated. The resulting Rotated.ps will be passed to ps2pdf without -dAutoRotatePages=/None but the Unrotated.ps will be passed to ps2pdf with -dAutoRotatePages=/None.

The following code throws some errors. The error messages can be seen by yourself.

% this input file name is filename.tex
% compile it with pdflatex -shell-escape filename.tex

\documentclass[preview,border=12pt]{standalone}

\usepackage{filecontents}

\begin{filecontents*}{temporary.tex}
\documentclass[pstricks,border=12pt]{standalone}
\begin{document}
\begin{pspicture}(4,2)
    \rput{90}(2,1){Marienplatz}
\end{pspicture}
\end{document}
\end{filecontents*}

\usepackage{graphicx,pgffor}

\newif\ifAutoRotatePages

\def\AutoRotatePages{%
    \ifAutoRotatePages
        % do nothing
    \else
        -dAutoRotatePages=/None
    \fi}

\def\JobName#1{-jobname=#1}

\foreach \outputname/\isautorotate in {Rotated/true,Unrotated/false}
{
    \AutoRotatePages\isautorotate
    \foreach \compiler/\ext in {latex \JobName{\outputname}/tex,dvips/dvi,ps2pdf \AutoRotatePages/ps}
    {
        \immediate\write18{\compiler\space \outputname.\ext}
    }
}

\begin{document}
\foreach \filename in {Rotated,Unrotated}{\begin{center}\includegraphics{\filename}\end{center}}
\end{document}

How to fix this problem?

6
 \AutoRotatePages\isautorotate

will pass a macro with value true or false to \AutoRotatePages so you could redefine your macro to accept such a string but simpler is just to do

 \csname AutoRotatePages\isautorotate\endcsname

together with

\def\AutoRotatePagestrue{}


\def\AutoRotatePagesfalse{ -dAutoRotatePages=/None }

No need for a new if

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.