Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 6 down vote accepted
 \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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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