Text FormattingFormatting in Beamer

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
Suppa808
Posts: 1
Joined: Sun Apr 26, 2015 6:49 am

Formatting in Beamer

Post by Suppa808 »

Hi, I'm turing a paper I wrote into a beamer presentation and when I copy the code from my paper and put it into beamer it doesn't compile correct and guidance would be great. Thanks.

Here's the code.

Code: Select all

\begin{frame}
\frametitle{Asset Modeling}
\begin{center}
  \begin{tikzpicture}[>=stealth,sloped]
    \matrix (tree) [%
      matrix of nodes,
      minimum size=1 cm,
      column sep=2.5 cm,
      row sep=.25cm,
    ]
    {
          &   & $S(0)(1+a)^2$ \\
          & S(0)(1+a) &   \\
      S(0) &   & S(0)(1+a)(1+b) \\
          & S(0)(1+b) &   \\
          &   & $S(0)(1+b)^2$ \\
    };
    \draw[->] (tree-3-1) -- (tree-2-2) node [midway,above] {$p$};
    \draw[->] (tree-3-1) -- (tree-4-2) node [midway,below] {$(1-p)$};
    \draw[->] (tree-2-2) -- (tree-1-3) node [midway,above] {$p^2$};
    \draw[->] (tree-2-2) -- (tree-3-3) node [midway,below] {$(1-p)p$};
    \draw[->] (tree-4-2) -- (tree-3-3) node [midway,above] {$(1-p)p$};
    \draw[->] (tree-4-2) -- (tree-5-3) node [midway,below] {$(1-p)^2$};
  \end{tikzpicture}
\end{center}
\end{frame}

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Formatting in Beamer

Post by Johannes_B »

Hi and welcome,

i am not a TikZ expert, i rarely use it. I think you need to escape the ampersands with back slashes, i.e. \& to make it work since beamer messes with category codes.

I couldn't test it though, because i cannot compile the code snippet. Stuff is needed and i don't know if it is part of some library or stuff defined locally by you. So, best always prepare something others can take and do tests with.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

Formatting in Beamer

Post by Stefan Kottwitz »

Welcome to the forum!

It doesn't compile because there's no \documentclass command. Something else could be missing. I guess you used it in the original but did not copy here. But this makes testing impossible. A Infominimal working example though is usually a guarantee for getting a solution. Besides quoting, mentioned by Johannes, I guess you need to define an ampersand replacement using an option in TikZ.

Stefan
LaTeX.org admin
Post Reply