2

My university wants a double sided thesis, but the dedication, the acknowledgement, the TOC and so on should be single sided.

My idea is to add the following code to a macro that already exists, but apply it to every page... The existing macro changes the page number style to roman and changes a few other styles. It's called immediately after \begin{document}. Before the main section of the thesis another macro is called that sets the page numbering to arabic and also applies some specific styles for the following pages.

The problem is, that I have no idea how to say LaTeX in the first macro that it should add \addblankpage after every page it compiles and to stop in the second macro.


\newcommand{\addblankpage}{%
    \clearpage%
    \thispagestyle{empty}%
    \addtocounter{page}{-1}%
    \clearpage%
}

\begin{document}

    \maketitle

    % Single sided, a blank page after every page should be generated
    \preface % The first macro

    \input{statutory-declaration}
    \input{note-of-thanks}
    \input{dedication}
    \input{abstract}

    \tableofcontents

    % Double sided, no extra page should be generated
    \main % The second macro

    \input{sections/introduction}
    \input{sections/experiments}
    \input{sections/interpretation}
    ...

\end{document}
  • Does this answer give you what you want? – marmot Feb 24 '18 at 18:45
  • @marmot this doesn't give blank pages for printing. – Skillmon Feb 24 '18 at 18:55
  • 1
    Please make your code compilable (if possible), or at least complete it with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem. Also, we don't have your local files, so remove the \inputs and replace them with some dummy stuff. – Skillmon Feb 24 '18 at 18:57
  • 1
    @koleygr or a Boolean which is switched. – Skillmon Feb 24 '18 at 19:03
  • 1
    @koleygr that's because its not in vertical mode inside of its hook, where \prevdepth isn't usable. – Skillmon Feb 24 '18 at 19:49
3

The following does what you want with the help of atbegshi.

\documentclass{article}

\usepackage{atbegshi,blindtext}

\title{I didn't post an MWE}
\author{The one who forgot to post an MWE}

\makeatletter
\newif\ifpreface@nextblank

\newcommand*\preface@blanks{}%
\let\preface@blanks\relax
\newcommand*\preface
  {%
    \global\preface@nextblanktrue
    \gdef\preface@blanks%
      {%
        \ifpreface@nextblank
          \thispagestyle{empty}%
          \addtocounter{page}{-1}%
          \mbox{}%
          \clearpage
          \global\preface@nextblankfalse
        \else
          \global\preface@nextblanktrue
        \fi
      }%
    \AtBeginShipout{\preface@blanks}
  }
\newcommand*\main
  {%
    \global\let\preface@blanks\relax
  }
\makeatother

\begin{document}

    \maketitle

    % Single sided, a blank page after every page should be generated
    \preface % The first macro

    \blinddocument

    \tableofcontents

    % Double sided, no extra page should be generated
    \main % The second macro

    \blinddocument

\end{document}

Stuff the above doesn't do (but would be nice):

  • check whether \preface is used on a left or right page
  • \clearpage(s) when \preface or \main are used onto the next right page
  • Thank you! That's awesome! Btw, I was just putting together an MWE as you posted this. Sorry again. – Sam Feb 24 '18 at 19:44
  • 1
    @koleygr now you do. I didn't know bophook. But tried to use it. \newpage (called by \clearpage) isn't executable in its hook, it seems because of \prevdepth. – Skillmon Feb 24 '18 at 19:48

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.