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}
Sam
  • 2,958
  • Does this answer give you what you want? –  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
  • Have you think of using the command \AtBeginPage{} of package bophook? Not tested, but a counter or \thepage could could help to "decide" when the command will be applied. – koleygr Feb 24 '18 at 19:01
  • 1
    @koleygr or a Boolean which is switched. – Skillmon Feb 24 '18 at 19:03
  • @Skillmon yes... it is an option too... – koleygr Feb 24 '18 at 19:11
  • Sorry for the missing MWE. I didn't post one because there was no problem in my code or so. For this question, only asking for a way to do this, I din't see a point in posting an MWE. I'll do it the next time. :-) – Sam Feb 24 '18 at 19:43
  • Always post an MWE. Always. (well there are exceptions but those are rare, if there is anything concerning code, post one if possible). – Skillmon Feb 24 '18 at 19:43
  • @Sam.. may be the one who will try to help you will not see a point of writing all the code from scratch too (Got it? Suppose you did... Not offensive at all... I tried anyway... But I want to make you understand why needed) – koleygr Feb 24 '18 at 19:44
  • @Skillmon our above idea was failing (probably \AtBeginPage works as an overlay and I could not use a \pagebreak or \clearpage etc) – koleygr Feb 24 '18 at 19:47
  • 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

1 Answers1

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
Skillmon
  • 60,462
  • 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