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?

2 Answers 2

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}
2
  • 1
    Thank your very much. Maybe, a rule of thumb could be: if doesn't work as expected, use "fragile". Jan 10, 2019 at 9:06
  • @CasséHugues that's the rule I used here:-) Jan 10, 2019 at 9:19
3

Use

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .