2

For the following MWE:

\documentclass[a4paper,12pt,addpoints]{exam}

\usepackage[]{geometry}
\usepackage{lipsum,graphbox,mdframed,array,ragged2e,booktabs,fmtcount,multicol,multirow,tabularx,cellspace,calc,tcolorbox,tikz,calc,fmtcount,etoolbox,soul}

\pagestyle{headandfoot}

\firstpagefooter%
{}%
{%
    \hrule\vspace{2pt}
    \begin{minipage}[t][][t]{0.5\textwidth}
        text
    \end{minipage}%
    \begin{minipage}[t][][t]{0.5\textwidth}
        \flushright Page \thepage\ of \numpages%
                \flushright\vspace{\baselineskip}Please Turn Over \begin{tikzpicture}[baseline=-\the\dimexpr\fontdimen22\textfont2\relax]\draw[-latex,line width=4pt]  (0,0) -- ++(10mm,0);\end{tikzpicture}%
    \end{minipage}%
}%
{}

\begin{document}
    \begin{questions}
        \question
        \lipsum
    \end{questions}
\end{document}

, this error shows up when drawing the tikz arrow

Font \nullfont has only 7 fontdimen parameters.

However, when removing the tikz drawing of the arrow in the footer

\firstpagefooter%
{}%
{%
    \hrule\vspace{2pt}
    \begin{minipage}[t][][t]{0.5\textwidth}
        text
    \end{minipage}%
    \begin{minipage}[t][][t]{0.5\textwidth}
        \flushright Page \thepage\ of \numpages%
                \flushright\vspace{\baselineskip}Please Turn Over
    \end{minipage}%
}%
{}

the error disappers.

So, I have two questions:

1- What causes this error when drawing the arrow?

2- Why isn't the arrow vertically aligned with the inline text as shown below?

enter image description here

Diaa
  • 9,599
  • 2
    why the low level primitive access \the\dimexpr\fontdimen22\textfont2\relax ? that is accessing param 22 of nullfont which isn't defined. – David Carlisle Nov 01 '18 at 07:45

2 Answers2

4

You need to ensure that the math fonts are correctly set up when you ask for \fontdimen22\textfont2, which can be done by issuing \check@mathfonts.

\documentclass[a4paper,12pt,addpoints]{exam}

\usepackage{geometry}
\usepackage{tikz}
\usepackage{lipsum}

\makeatletter
\newcommand\turnover{%
  \check@mathfonts % ensure math fonts are defined
  \begin{tikzpicture}[baseline=-\the\dimexpr\fontdimen22\textfont2\relax]
    \draw[-latex,line width=4pt]  (0,0) -- ++(10mm,0);
  \end{tikzpicture}%
}
\makeatother

\pagestyle{headandfoot}

\firstpagefooter%
  {}%
  {%
   \hrule\vspace{2pt}
   \begin{minipage}[t]{0.5\textwidth}
     text
   \end{minipage}%
   \begin{minipage}[t]{0.5\textwidth}
     \raggedleft
     Page \thepage\ of \numpages\\[\baselineskip]
     Please Turn Over \turnover
   \end{minipage}%
  }%
  {}

\begin{document}

\begin{questions}
  \question
  \lipsum
\end{questions}

\end{document}

Note that you should not use \flushright, but \raggedleft.

enter image description here

egreg
  • 1,121,712
2

Perhaps you want this

\documentclass[a4paper,12pt,addpoints]{exam}

\usepackage[]{geometry}
\usepackage{lipsum,graphbox,mdframed,array,ragged2e,booktabs,fmtcount,multicol,multirow,tabularx,cellspace,calc,tcolorbox,tikz,calc,fmtcount,etoolbox,soul}

\pagestyle{headandfoot}

\firstpagefooter%
{}%
{%
    \hrule\vspace{2pt}
    \begin{minipage}[t][][t]{0.5\textwidth}
        text
    \end{minipage}%
    \begin{minipage}[t][][t]{0.5\textwidth}
        \flushright Page \thepage\ of \numpages%
        \flushright\vspace{\baselineskip}Please Turn Over
    $\vcenter{\hbox{\begin{tikzpicture}\draw[-latex,line width=4pt]  (0,0) -- ++(10mm,0);\end{tikzpicture}}}$%
    \end{minipage}%
}%
{}

\begin{document}
    \begin{questions}
        \question
        \lipsum
    \end{questions}
\end{document}

enter image description here