7

The code is below:

\documentclass[a4paper]{beamer}
\usepackage[utf8]{inputenc}
\title{Ok}
\author{Me}
\date{\today}

\newif\ifok
\oktrue

\begin{document}

\maketitle

\begin{frame}
    \ifok
    Hello
    \begin{tabular}{c}
        ok \\
    \end{tabular}
    \fi 
\end{frame}

\end{document}

This small code piece makes pdflatex to outout (only last lines):

! Incomplete \ifx; all text was ignored after line 19.
<inserted text> 
                \fi 
<*> ok.tex

? 
! Emergency stop.
<inserted text> 
                \fi 
<*> ok.tex

!  ==> Fatal error occurred, no output PDF file produced!

Any idea to fix this or should I throw out the use of \newif?

5

Beamer does lots of "interesting" re-arrangements of its inputs, you can use the [fragile] option on a frame so it uses a safer, slower, mechanism:

\documentclass[a4paper]{beamer}
\usepackage[utf8]{inputenc}
\title{Ok}
\author{Me}
\date{\today}

\newif\ifok
\oktrue

\begin{document}

\maketitle

\begin{frame}[fragile]

    \ifok
    Hello
    \begin{tabular}{c}
        ok \\
    \end{tabular}
    \fi

\end{frame}

\end{document}
|improve this answer|||||
  • 1
    Thank your very much. Maybe, a rule of thumb could be: if doesn't work as expected, use "fragile". – Cassé Hugues Jan 10 '19 at 9:06
  • @CasséHugues that's the rule I used here:-) – David Carlisle Jan 10 '19 at 9:19
3

Use

\begin{frame}
    \ifok
    Hello
    {\begin{tabular}{c}
        ok \\
    \end{tabular}}
    \fi 
\end{frame}
|improve this answer|||||

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.