0

With the following code, the text

This is an experiment!

is not placed in the indicated pages: 1, 2 and 4.

Could somebody please help me?

\documentclass[12pt]{article}

\usepackage{lipsum}
\usepackage{afterpage,everypage}
\usepackage{tikz}
\usepackage{xstring}

\newcommand*{\MyList}{1,2,4}

\newcommand*{\AddMyText}{
    \foreach \x in \MyList {
        \IfEq{\arabic{page}}{\x}{
           \afterpage{\noindent \centering This is an experiment!}
           \breakforeach%
        }
    }
}

\begin{document}

\AddEverypageHook{\AddMyText}

\lipsum[1-50]

\end{document}
  • 1
    normally such text would be in the page heading, do you really need it to be in the main text block? – David Carlisle Jun 3 at 0:00
  • Just remove \afterpage and add \par after "experiment!" – Fran Jun 3 at 0:04
  • @Fran Thanks! That works. – Paul Smith Jun 3 at 0:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.