0

I am using Overleaf to make a beamer style presentation. The following code works fine in the text editor but will not compile. The following code works fine in other files as well. Actually, all my equations that work fine elsewhere (I am using Typora) are not compiling here.

[UPDATE]

  1. I have opened an new template. It works well without adding new
    frames.

  2. Then I added only one line of code, my equation. It shows
    errors

  3. Then I removed my equations. It works fine.

The only code I added is at line 40, which is an equation.

I have included the template links: https://www.overleaf.com/latex/examples/writing-beamer-slides-with-markdown/dnrwnjrpjjhw#.WxKytEgvyUl

enter image description here

\documentclass{beamer}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{mathabx}
\usepackage{mathpazo}
\usepackage{eulervm}
\usepackage{natbib}

%% Load the markdown package
\usepackage[citations,footnotes,definitionLists,hashEnumerators,smartEllipses,tightLists=false,hybrid]{markdown}
\markdownSetup{rendererPrototypes={
 link = {\href{#2}{#1}},
 headingThree = {\begin{frame}\frametitle{#1}},
 headingFour = {\begin{block}{#1}},
 horizontalRule = {\end{block}}
}}


\usetheme{Dresden}
\usefonttheme{serif}
\usecolortheme{rose}


\title{Writing Beamer Slides with Markdown}
\author{LianTze Lim}
\institute{Overleaf}

\begin{document}

\maketitle

\frame{\tableofcontents}

\begin{markdown}

## How?

### We can do that?

$ Q_{ijt}^{A} \sim N (Q_{j}, \sigma^2_{A}) $

- Yeah to some extent, with \texttt{markdown} package :-)
    - __$\hash$__ and __$\hash\hash$__ for section and subsection headers (in ToC)
    - Redefine __$\hash\hash\hash$__ to start a frame and frametitle
    - (Nested) bullet and numbered lists
    - Text formatting (*italic*, **bold becomes italic + alerted**) 
    - Redefine __$\hash\hash\hash\hash$__ to start a block with title \linebreak
      and __\texttt{-{}-{}-{}-}__ to end the block
    - ___Compile with \texttt{-{}-shell-escape}___ (Overleaf does this already)
- (Alternative approaches: Pandoc, wikitobeamer)

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%

### Caveats

- Nothing too complicated! 
- No verbatim or fragile stuff!
- No $\hash$ and \textunderscore{} characters!\linebreak 
  (I used `$\hash$` and `\textunderscore`)
- Can't pass options to frames
- __Need to write \texttt{\textbackslash end\string{frame\string}} manually!__

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%


%%% # and ## are still sections and subsections
# Example

## Proposed Menus

%%% ### starts a frame + frametitle
### Breakfast Menu

%%% bulleted lists as usual 

- Eggs
    * scrambled
    * sunny-side-up
- Coffee
    * Americano
    * Long black
- Tea
    * Darjeeling
    * English Breakfast

%%% Due to the complicatedness of beamer frames, \end{frame} MUST appear in the source code itself and cannot be "hidden" in another command

\end{frame}

%%%%%%%%%%%

### Lunch Menu

- Spaghetti
    * Bolognese
    * Aglio olio
- Sandwiches
    * Egg
    * Ham
    * Tuna

\end{frame}

%%%%%%%%%%%

## Budgeting

### Projected Profit

1. And the answer is...
2. $f(x)=\sum_{n=0}^\infty\frac{f^{(n)}(a)}{n!}(x-a)^n$
    #. How do we _know_ that?
    #. __Maths!__

\end{frame}

### Testing blocks

#### This is a block!

- Here is some content.
- Here's more contents.

---

\end{frame}


### Citations

- This is a book [@BookKey]
- This is an article [@ArticleKey]

\end{frame}

\end{markdown}

\begin{frame}
\renewcommand{\bibfont}{\footnotesize}
\frametitle{Bibliography}

\bibliographystyle{apalike}
\bibliography{refs}

\end{frame}


\end{document}
19
  • 2
    please, provide code in form of complete small document beginning with \documentclass{beamer}` and ending with \end{document}, which show your problem, not its image. your code fragment is not cause of your problem.
    – Zarko
    Jun 2 '18 at 5:02
  • 1
    The error message complains about line 185. You circled a different line that should be ignored by beamer.
    – Johannes_B
    Jun 2 '18 at 5:19
  • 1
    The error message says something about \itshape not being valid in math mode, yet your code features no \itshape instructions. As your query stands, it cannot be answered. (Aside: \itshape is a text mode command and should therefore definitely not be used in math mode...)
    – Mico
    Jun 2 '18 at 5:23
  • 1
    There seems to be some terminological confusion. For sure, LaTeX does not employ "markdown"; instead, it's a mark-up language. (AFAICT, the term "markdown" was coined as perhaps-a-bit-too-clever pun on the term "mark-up", which is much older.) In the code you posted, the symbol $ serves to initiate and terminate inline-style math mode. There's also a second form of math mode: display-stye math mode. How to enter equations depends crucially on whether one wishes to employ inline or display style. Please study any introduction to LaTeX to familiarize yourself with the terminology.
    – Mico
    Jun 2 '18 at 5:45
  • 4
    Your error message mentions line 185. So the problematic code is in the frame ending at this line. That is above the position you are showing currently. Jun 2 '18 at 7:38
4

The problem is that you have multiple _ in your formula which markdown recognises as italic. If you want to use them as subscripts, either use the markdown package with underscores=false option or escape them.

Answer 1: Escaping

% !TeX program = txs:///arara
% arara: pdflatex: {synctex: on, interaction: nonstopmode, shell: yes}
\documentclass{beamer}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{mathabx}

%% Load the markdown package
\usepackage[citations,footnotes,definitionLists,hashEnumerators,smartEllipses,tightLists=false,hybrid]{markdown}
\markdownSetup{rendererPrototypes={
 link = {\href{#2}{#1}},
 headingThree = {\begin{frame}\frametitle{#1}},
 headingFour = {\begin{block}{#1}},
 horizontalRule = {\end{block}}
}}

\begin{document}

\begin{markdown}

### We can do that?

$ {Q\_{ijt}} Q\_{j} $

\end{frame}

\end{markdown}

\end{document}

Answer 2: underscore=false

Please not that with this solution _ can no longer be used as markdown elements.

% !TeX program = txs:///arara
% arara: pdflatex: {synctex: on, interaction: nonstopmode, shell: yes}
\documentclass{beamer}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{mathabx}

%% Load the markdown package
\usepackage[citations,footnotes,definitionLists,hashEnumerators,smartEllipses,tightLists=false,hybrid,underscores=false]{markdown}
\markdownSetup{rendererPrototypes={
 link = {\href{#2}{#1}},
 headingThree = {\begin{frame}\frametitle{#1}},
 headingFour = {\begin{block}{#1}},
 horizontalRule = {\end{block}}
}}

\begin{document}

\begin{markdown}

### We can do that?

$ {Q_{ijt}} Q_{j} $

- Yeah to some extent, with \texttt{markdown} package :-)
    - $\hash$ and $\hash\hash$ for section and subsection headers (in ToC)
    - Redefine $\hash\hash\hash$ to start a frame and frametitle
    - (Nested) bullet and numbered lists
    - Text formatting (*italic*, **bold becomes italic + alerted**) 
    - Redefine $\hash\hash\hash\hash$ to start a block with title \linebreak
      and \texttt{-{}-{}-{}-} to end the block
    - Compile with \texttt{-{}-shell-escape} (Overleaf does this already)
- (Alternative approaches: Pandoc, wikitobeamer)

\end{frame}

\end{markdown}

\end{document}
9
  • How to set underscores=false? Jun 2 '18 at 17:41
  • @alphabetagamma \usepackage[underscores=false, .... Jun 2 '18 at 18:10
  • @samcarter, please be so kind and edit your answer where consider underscores=false and show, how to be changed text (list?) which in question follows equation. if i added it to your answer, it gives error (missing $).
    – Zarko
    Jun 3 '18 at 10:32
  • @Zarko With underscores=false the underscore can no longer be used for italic. I will edit Jun 3 '18 at 10:36
  • @Zarko edited__ Jun 3 '18 at 10:41

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.