1

I am writing a document which needs a multicols environment stretching over multiple pages. Moreover I am intending to use \thepage in the body of the environment. To be specific I need to know whether the page ist odd or even.

After getting some weird results I realized, that the multicols package does not seem to step the page counter, unless a manual \newpage is issued.

MWE:

\begin{filecontents*}{\jobname.xmpdata}
\Title{title}
\Author{author}
\end{filecontents*}
\documentclass[a4paper,11pt,twoside,parskip=half]{scrartcl}

\usepackage[x-1a]{pdfx}
\usepackage[ngerman]{babel}

\usepackage{blindtext}
\usepackage{multicol}

\begin{document}
  \begin{multicols}{2}
    \blindtext\\
    \textbf{PAGE: \thepage}\\
    \columnbreak
    \blindtext\\
    \textbf{PAGE: \thepage}\\
    \blindtext
    \blindtext
    \blindtext\\
    \textbf{PAGE: \thepage}\\
    \blindtext
    \newpage
    \blindtext\\
    \textbf{PAGE: \thepage}\\
  \end{multicols}
\end{document}

Thanks in advance for any help

  • 1
    irrespective of multicols you can never use \thepage within the body of the document to refer to the current page. use \label{x} then access the page number via \pageref{x} – David Carlisle Feb 26 '18 at 23:12
  • 1
    consider a single one paragraph document that spans several pages, \thepage will have the value it has at the start of the paragraph on all the pages because as in your example here, all macros are expanded before paragraphs are broken into lines and lines are broken in to pages. – David Carlisle Feb 26 '18 at 23:15
  • So if I want a command that is called multiple times a page and draws something to the left border on even pages and to the right border on odd pages, each time the command is called I would have to set up a label to \pageref to? – user176881 Feb 26 '18 at 23:36
  • 1
    most likely but it depends what kind of command it is, if it needs to be within a paragraph then it is really hard to do what you ask in full generality, as as I say the whole paragraph is set before page breaking is known, if the command is between paragraphs, \pageref works easily enough, and as you note above after a forced page break it's easy as you can access the page counter directly. – David Carlisle Feb 26 '18 at 23:46
  • Why are you breaking lines with \\ anyway? – cfr Feb 27 '18 at 03:22

0 Answers0