1

I am trying to create a presentation using beamer. I need to draw something using tikz and provide some code listings. However, I get the error

! Package tikz Error: Sorry, some package has redefined the meaning of the math
-mode dollar sign. This is incompatible with tikz and its calc library and migh
t cause unrecoverable errors.

I looked through some questions with the same problem, but I still do not understand how to solve my problem.

Here is my code

\documentclass[aspectratio=169]{beamer}

\usepackage{CJKutf8}
\usepackage{listings}
\usepackage{tikz}

\begin{document}
\begin{CJK}{UTF8}{gbsn}

\begin{frame}
 \frametitle{title}
 \begin{columns}[T]
  \begin{column}[T]{5cm}
   \begin {tikzpicture}
    \filldraw (0, 0) circle (2pt) node[below] {1};
   \end{tikzpicture}
  \end{column}
  \begin{column}[T]{5cm}
   \begin{lstlisting}
   code
   \end{lstlisting}
  \end{column}
 \end{columns}
\end{frame}

\newpage
\end{CJK}
\end{document}

I am running pdflatex command from texlive in a Fedora machine. Any helps will be appreciated.

1 Answer 1

6

When using listings with beamer, you need to add the [fragile] option after \begin{frame} if the frame contains a listing. Otherwise beamer cannot deal properly with the listing, that is somehow simlar to verbatim.

From the beamer doc

The ⟨environment contents⟩ [of a frame] can be normal LaTeX text, but may not contain \verb commands or verbatim environments or any environment that changes the character codes, unless the fragile option is given.

This includes the listing environment.
Note that the error message in this situation is never very explicit. For instance, if you suppress the tikz picture, you get the message

Package Listings Warning: Text dropped after begin of listing on input line 27.

And you can have other weird and misleading messages like yours.

You must log in to answer this question.

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