Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I was trying to put code and a figure side by side in a beamer presentation. I tried two methods - one said in beamer documentation and other in standard LaTeX. But couldn't get the output. The two column thing works well if I don't have any code in it. I tried both listings and verbatim, with fragile option but in vein.

The code I gave was

\begin{frame}
\begin{columns}
\column[t]{5cm}
Two
\column[t]{5cm}
test
\end{columns}

This works well. But when I gave code with fragile option it gave error. Code without fragile option also gave error.

\begin[fragile]{frame}
\begin{columns}
\column[t]{5cm}
\begin{verbatim}
Two
\end{verbatim}
\column[t]{5cm}
test
\end{columns}

The error I got is (From Log file)

 [8
] [9
]
! Missing $ inserted.
<inserted text>
$
l.100
I've inserted a begin-math/end-math symbol since I think
you left one out. Proceed, with fingers crossed.
! Display math should end with $$.
<to be read again>
\par
l.100
The `$' that I just saw supposedly matches a previous `$$'.
So I shall assume that you typed `$$' both times.
! You can't use `\unskip' in vertical mode.
\beamer@smuggle ...@zeropt \else \ifvmode \unskip
\fi \ifhmode \unskip \fi \...
l.102 \column
[t]{5cm}
Sorry...I usually can't take things from the current page.
Try `I\vskip-\lastskip' instead.
! Extra }, or forgotten \endgroup.
\endframe ->\egroup
\begingroup \def \@currenvir {frame}
l.110 \end{frame}
I've deleted a group-closing symbol because it seems to be
spurious, as in `$x}$'. But perhaps the } is legitimate and
you forgot something else, as in `\hbox{$x}'. In such cases
the way to recover is to insert both the forgotten and the
deleted material, e.g., by typing `I$}'.
[10
]
\tf@nav=\write6
\openout6 = `latex.nav'.
\tf@toc=\write7
\openout7 = `latex.toc'.
\tf@snm=\write8
\openout8 = `latex.snm'.
! LaTeX Error: \begin{equation*} on input line 88 ended by \end{document}.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...

I also got error without code, with fragile option included. I also tried the following but in vein

\begin[fragile]{frame}
\frametitle{Structure of a \LaTeX\ document}
\begin{columns}
\begin{column}{0.5\textwidth}
\begin{semiverbatim}
test
\end{semivrbatim}
\end{column}
\begin{column}{0.5\textwidth}
\includegraphics[scale=.2]{hello}
\end{column}
\end{frame}
\end{columns}
share|improve this question

2 Answers 2

up vote 7 down vote accepted

The right syntax is

\begin{frame}[fragile]

Here's your example:

\documentclass{beamer}

\begin{document}

\begin{frame}[fragile]
\begin{columns}
\column[t]{5cm}
\begin{verbatim}
Two
\end{verbatim}
\column[t]{5cm}
test
\end{columns}
\end{frame}

\end{document}

enter image description here

share|improve this answer

Your syntax is not correct: \begin{frame}[fragile], not \begin[fragile]{frame}.

The following works (even if you replace the verbatim environment with lstlisting from listings):

enter image description here

\documentclass{beamer}% http://ctan.org/pkg/beamer
\begin{document}
\begin{frame}[fragile]
  \frametitle{Structure of a \LaTeX\ document}
  \begin{columns}
    \begin{column}{0.5\textwidth}
\begin{verbatim}
test code
here is some more stuff
172 192 d9a $^&2 ()%$
\end{verbatim}
    \end{column}
    \begin{column}{0.5\textwidth}
      \includegraphics[width=.7\linewidth]{example-image-a}
    \end{column}
  \end{columns}
\end{frame}
\end{document}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.