1
\documentclass{article}
\usepackage{geometry}
\usepackage{fontspec}
\usepackage{flowfram}
\usepackage{tikz}
\usepackage{ifthen}
\usepackage{changepage}
\usepackage{ifoddpage}
\usepackage{lipsum}

\geometry{paperwidth=29.7cm,paperheight=7cm,margin=0cm}
\pagestyle{empty}

\newcommand{\pechafront}{
    \newdynamicframe{29.7cm}{7cm}{0cm}{0cm}[front]
    \setdynamiccontents*{front}{
        \vfil\hfil
        \begin{tikzpicture}
            \draw[color=black,very thick] (2.7,.93) rectangle +(24.3,5.14)
            (2.77,1) rectangle +(24.16,5)
            (3.77,1) rectangle +(.07,5)
            (25.97,1) rectangle +(.07,5);
            \node[rotate=-90] at (3.2,3.5) {\huge \thepage};
            \node[rotate=90] at (26.47,3.5) {\huge \thepage};
        \end{tikzpicture}
    }
    \newflowframe{21.7cm}{4.9cm}{4cm}{.9cm}[frontframe]
}

\newcommand{\pechaback}{
    \newdynamicframe{29.7cm}{7cm}{0cm}{0cm}[back]
    \setdynamiccontents*{back}{
        \begin{tikzpicture}
            \draw[color=black] (0,0) +(29.7,7)
            (3.77,1) rectangle +(22.16,5.12)
            (2.77,1) rectangle +(24.16,5.12);
            \node[rotate=90] at (3.43,3.5) {\huge \thepage};
            \node[rotate=-90] at (26.33,3.5) {\huge \thepage};
    \end{tikzpicture}}
    \newflowframe{21.7cm}{4.9cm}{4.0cm}{0.9cm}[backframe]
}

\sloppy

\checkoddpage
\ifoddpage
    \pechafront
\else
    \pechaback
\fi
\begin{document}
\lipsum
\lipsum
\end{document}

The pages render as if they are all odd. What am I doing wrong?

EDIT: I'm running this under LuaLaTeX

2
  • 2
    I don't use lualatex and don't know ifoddpage etc, but shouldn't this test be done on any page, i.e. in a page shipout hook?
    – user31729
    Sep 9, 2014 at 22:25
  • @ChristianHupfer I have no idea. I'm learning as I'm going here. If you know anything about this, I would really appreciate some more explanation.
    – jollyroger
    Sep 9, 2014 at 22:27

1 Answer 1

2

I think you can just specify the page list as even or odd in the optional argument when defining the dynamic frames.

\documentclass{article}
\usepackage{geometry}
\usepackage{fontspec}
\usepackage{flowfram}
\usepackage{tikz}
\usepackage{ifthen}
\usepackage{changepage}
\usepackage{ifoddpage}
\usepackage{lipsum}

\geometry{paperwidth=29.7cm,paperheight=7cm,margin=0cm}
\pagestyle{empty}


\newdynamicframe[odd]{29.7cm}{7cm}{0cm}{0cm}[front]
\setdynamiccontents*{front}{
    \vfil\hfil
    \begin{tikzpicture}
        \draw[color=black,very thick] (2.7,.93) rectangle +(24.3,5.14)
        (2.77,1) rectangle +(24.16,5)
        (3.77,1) rectangle +(.07,5)
        (25.97,1) rectangle +(.07,5);
        \node[rotate=-90] at (3.2,3.5) {\huge \thepage};
        \node[rotate=90] at (26.47,3.5) {\huge \thepage};
    \end{tikzpicture}
}
\newdynamicframe[even]{29.7cm}{7cm}{0cm}{0cm}[back]
\setdynamiccontents*{back}{
    \begin{tikzpicture}
        \draw[color=black] (0,0) +(29.7,7)
        (3.77,1) rectangle +(22.16,5.12)
        (2.77,1) rectangle +(24.16,5.12);
        \node[rotate=90] at (3.43,3.5) {\huge \thepage};
        \node[rotate=-90] at (26.33,3.5) {\huge \thepage};
\end{tikzpicture}}
\newflowframe{21.7cm}{4.9cm}{4cm}{.9cm}[myframe]

\sloppy% this is very bad - do you really need this for your entire document?

\begin{document}
\lipsum
\lipsum
\end{document}

Alternating designs

EDIT

Changing things for a single page is less straightforward. However, you could use afterpage and a bit of fiddling like this:

\documentclass{article}
\usepackage{geometry}
\usepackage{fontspec}
\usepackage{flowfram}
\usepackage{tikz}
\usepackage{ifthen}
\usepackage{changepage}
\usepackage{lipsum}
\usepackage{afterpage}

\geometry{paperwidth=29.7cm,paperheight=7cm,margin=0cm}
\pagestyle{empty}


\newdynamicframe[odd]{29.7cm}{7cm}{0cm}{0cm}[front]
\newdynamicframe[even]{29.7cm}{7cm}{0cm}{0cm}[back]
\newflowframe{21.7cm}{4.9cm}{4cm}{.9cm}[myframe]
\setdynamiccontents*{front}{
    \vfil\hfil
    \begin{tikzpicture}
        \draw[color=black,very thick] (2.7,.93) rectangle +(24.3,5.14)
        (2.77,1) rectangle +(24.16,5)
        (3.77,1) rectangle +(.07,5)
        (25.97,1) rectangle +(.07,5);
        \node[rotate=-90] at (3.2,3.5) {\huge \thepage};
        \node[rotate=90] at (26.47,3.5) {\huge \thepage};
    \end{tikzpicture}
}
\setdynamiccontents*{back}{
    \begin{tikzpicture}
        \draw[color=black] (0,0) +(29.7,7)
        (3.77,1) rectangle +(22.16,5.12)
        (2.77,1) rectangle +(24.16,5.12);
        \node[rotate=90] at (3.43,3.5) {\huge \thepage};
        \node[rotate=-90] at (26.33,3.5) {\huge \thepage};
\end{tikzpicture}}

\sloppy

\begin{document}
\lipsum[1-2]
\lipsum[3-4]
\dynamicsetpagelist{2}{none}
\dynamicsetpagelist{1}{\thepage}
\afterpage{%
  \dynamicsetpagelist{2}{even}
  \dynamicsetpagelist{1}{odd}
}
\lipsum[5-8]
\end{document}

switched on page 2

4
  • Thank you ever so much! That was the perfect answer. The \sloppy is very much needed unfortunately. It has to do with rendering Tibetan using the polyglossia package and XeTeX\LuaTex
    – jollyroger
    Sep 9, 2014 at 23:02
  • Do you know of a way to manually force the "frontframe" for one page, no matter if the page is even or odd? Perhaps some macro to manually insert in my text wherever I would need to force a "frontframe".
    – jollyroger
    Sep 9, 2014 at 23:08
  • @jollyroger No, sorry. I had one idea but it turned out to be hopelessly incompatible with reality. So I'm afraid I have no idea how you can do that except by temporarily redefining the contents of the relevant dynamic frame.
    – cfr
    Sep 9, 2014 at 23:18
  • 1
    @jollyroger See my edited answer for a way to use afterpage to do this. Is that what you meant? Note that according to the manual, you must use the IDN rather than an IDL in this case.
    – cfr
    Sep 9, 2014 at 23:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .