I am using pandoc to generate a beamer slideshow. I activated the generation of a TOC and specified a TOC headline. But there is an extra number added to this title as if the TOC would span several slides, but it does not.
My source file
---
toc: true
toc-title: the overview
...
# my section
and I compile with pandoc -t beamer -o x.pdf < x.md. The title of the TOC has this extra roman I which beamer normally adds if a slide is split into two (or more).
How can I get rid of this number?
Edit
In the end I put it in the yaml preamble of the pandoc file as raw latex code:
header-includes: |
```{=latex}
\setbeamertemplate{frametitle continuation}[from second]
% more stuff
```
You can disable the continuation count for frames that consist only of a single one by using this command:
\setbeamertemplate{frametitle continuation}[from second]
In the response from #samcarter_is_at_topanswers.xyz, I had to delimit the command with backticks and indicate as latex code:
`\setbeamertemplate{frametitle continuation}[from second]`{=latex}
Related
I cannot get column width recognized. It is as if it is just ignored and each column is exactly 50% of the available space. Additionally the example implies I can tell it when I want the 2nd column to start but that is also ignored.
The following is from the Pandoc manual column example, but when I compile it via pandoc they are just each 50% width not what is specified. The frontmatter in my example was not provided in their example but its what I figure it must be to get the columns working. I've tried this with and without the frontmatter.
I'm using ubuntu 18.04 within WSL2 and pandoc version:
pandoc 2.17.1.1 Compiled with pandoc-types 1.22.1, texmath 0.12.4,
skylighting 0.12.2, citeproc 0.6.0.1, ipynb 0.2
I'm using these command line entry for compiling it: (I've also tried pdflatex engine as well)
pandoc mat_doc.md --pdf-engine=xelatex -o mat_doc.pdf
Here is the file:
---
output: pdf_document
classoption: twocolumn
---
:::::::::::::: {.columns}
::: {.column width="60%"}
contents
:::
::: {.column width="40%"}
contents
:::
::::::::::::::
How do I get different sized columns? Why does this not work per their manual? Thx!
The beamer columns you are trying to use, are something special in the beamer class and don't work with normal classes.
However under the hood, these columns are just glorified minipages - and these you can use in normal latex classes.
---
output: pdf_document
---
\noindent\begin{minipage}{.6\textwidth}
test
\end{minipage}
\begin{minipage}{.4\textwidth}
test
\end{minipage}
I am using the bookdown to write a book. I've defined the documentclass as book. Everything seems to be working correctly - the Table of Contents, List of Tables and List of Figures along with an Appendix, Bibliography and Index. However, in my index.Rmd file I lead off with a Preface section that is not numbered. So, this first "Preface chapter" is marked with a level-1 heading # Preface {-}. The Preface is listed correctly in the Table of Contents as an unnumbered Chapter. However, on the page following the "Preface chapter" the heading at the top of the page still says "List of Figures". So, somehow the chapter heading is being held over and repeated from the List of Figures and not being updated with the "Preface chapter" heading. This "List of Figures" heading stays the same until I get to the next chapter (technically the second chapter) which is numbered, then the rest of the page headings are correct for the rest of the book.
I'm a bit of a LaTeX newbie, so I'm sure there is some option or setting I'm missing. Do I need to add some special LaTeX command or Pandoc argument to make sure that the page headings are aligned with every chapter - both numbered and unnumbered?
Any suggestions are much appreciated. My relevant YAML settings and TEX commands are listed below.
_output.yml
bookdown::pdf_book:
includes:
in_header: preamble.tex
after_body: after_body.tex
latex_engine: xelatex
citation_package: natbib
keep_tex: yes
preamble.tex
\usepackage{booktabs}
\usepackage{makeidx}
\makeindex
\usepackage[nottoc]{tocbibind}
index.Rmd - relevant section of YAML
documentclass: book
bibliography: [manual.bib, packages.bib]
biblio-style: apalike
link-citations: yes
lot: true
lof: true
Since pandoc passes LaTeX commands through you could use
# Preface {-}
\markboth{Preface}{}
(c.f. https://tex.stackexchange.com/questions/89914/chapter-name-in-the-header-with-chapter)
I am creating pdf slides using rmarkdown and beamer. When using latex instead of rmarkdown, I can include arbitrary pages from pdf files into my slides with
\usepackage{pdfpages}
...
\includepdf[pages={1-10}]{another_file.pdf}
Is it possible to achieve this with rmarkdown? Note that when just issuing the \includepdf command, intended to be located between slides, pandoc wraps it between \begin{frame} and \end{frame}.
Not a perfect solution but it works (adapted from https://tex.stackexchange.com/questions/11458/error-when-inserting-a-pdf-page-into-a-beamer-presentation?newreg=10fd6a4a46c642118eb4ec905cf87303): use \includegraphics instead of includepdf. This works inside of frames but you have to manyally create a frame for each page you want to insert as it only allows to insert a single page at time.
---
title: "Foo"
output:
beamer_presentation:
---
# Stolen image
---
\includegraphics[page=1,width=\paperwidth]{lecture-1-terminal.pdf}
# My own work
## My slide 1
Great stuff!
In rmarkdown you can use pdfpages like this:
---
output:
beamer_presentation:
keep_tex: true
header-includes:
- \usepackage{pdfpages}
- \setbeamercolor{background canvas}{bg=}
- \makeatletter\beamer#ignorenonframefalse\makeatother
---
test
``` {=latex}
\end{frame}
\includepdf[pages=1-10]{example-image-duck}
\begin{frame}
```
test
(the line \setbeamercolor{background canvas}{bg=} is necessary for beamer versions < 3.64, a patch has been added in 9e3bb9)
As you mentioned, you can inlcude raw TeX in Pandoc Markdown. For me the following works:
$ pandoc -t beamer
foo
\includepdf[pages={1-10}]{another_file.pdf}
bar
^D
which results in:
\begin{frame}
foo
\includepdf[pages={1-10}]{another_file.pdf}
bar
\end{frame}
Maybe you need to update your pandoc version? (I'm currenlty using 2.0 from pandoc nightlies)
What is the way to change the style of numbers in ordered lists generated by Pandoc?
For the following Markdown input
1. One
2. Two
1. Sub 1
2. Sub 2
Pandoc generates the following Latex output
\begin{enumerate}
\def\labelenumi{\arabic{enumi}.}
\itemsep1pt\parskip0pt\parsep0pt
\item
One
\item
Two
\begin{enumerate}
\def\labelenumii{\arabic{enumii}.}
\itemsep1pt\parskip0pt\parsep0pt
\item
Sub 1
\item
Sub 2
\end{enumerate}
\end{enumerate}
This results in the following PDF output:
1. One
2. Two
1. Sub 1
2. Sub 2
While I'm trying to achieve
1. One
2. Two
2.1. Sub 1
2.2. Sub 2
I tried to redefine style of numbering in the default template with these commands
\renewcommand{\labelenumii}{\theenumii}
\renewcommand{\theenumii}{\theenumi.\arabic{enumii}.}
but as Pandoc generates explicit definition for labelenumii this solution does not work.
Update
It turns out that the problem could be resolved by using #. notation instead of 1. one. For whatever reason Pandoc skips styling only for lists defined this way and interprets the standard Markdown notation as an instruction to style list with plain numbers. Hopefully in future versions it will be a bit more flexible and will add the support for nested numbers in lists.
edit
This function of the latex writer that adds the \def\labelenumi{} part checks for numstyle == DefaultStyle && numdelim == DefaultDelim. As #oleg found out, this might be accomplished with #. list markers, so that this should work:
---
header-includes:
- \renewcommand{\labelenumii}{\theenumii}
- \renewcommand{\theenumii}{\theenumi.\arabic{enumii}.}
---
#. One
#. Two
#. Sub 1
#. Sub 2
There are two feature requests asking for a native markdown solution on the issue tracker (336 and 1627), as well as a discussion on the mailing list.
pre-edit answer
Of course, you could always compile to latex, postprocess the file to remove those \def\labelenumi{} lines, and then compile the latex file. Here is an example that works with the standard latex template.
test.md
---
header-includes:
- \renewcommand{\labelenumii}{\theenumii}
- \renewcommand{\theenumii}{\theenumi.\arabic{enumii}.}
---
1. One
2. Two
1. Sub 1
2. Sub 2
commands:
pandoc test.md -t latex -s | sed '/\\def\\labelenumi/d' > test.tex
xelatex test.tex
But all the lists of your document will be affected, and you need to write the latex compilation commands yourself.
I am using pandoc to generate a pdf from some markdown. I am using h1 through h4 via hash symbols. Example h1=#, h4=####. When I generate my document like this:
pandoc input.md -o output.pdf
I get a document where h1, h2 and h3 have a newline after them but h4 does not have a new line. The text starts on the same line as the header (it isn't formatted the same way, but there isn't a newline character between).
I've tried adding spaces after the #### and adding manual line returns using my editor but nothing seems to work.
Any ideas?
While the mentioned solutions work fine, pandoc offers a build-in variable to enable block-headings for \paragraph.
pandoc -s -o out.pdf some.md -V block-headings
Pandoc Manual
pandoc generates PDFs via LaTeX. In LaTeX, "headers" are generated using the following commands:
\section
\subsection
\subsubsection
\paragraph
\subparagraph
As you can see, a "level four heading" corresponds to the \paragraph command, which is rendered as you describe. There simply isn't a \subsubsubsection command to use.
The only way to get what you want is to redefine the \paragraph command, which is quite tricky. I haven't been able to make it work with Pandoc.
While #tarleb’s answer is surely the best (except that it specifies a
wrong amount of vertical space), here is a “simpler” (by some measure)
but more hacky (in LaTeX terms at least) solution which optionally uses a Pandoc Lua filter or a LaTeX hack but avoids loading another LaTeX package.
We want the LaTeX source to look something like this:
\hypertarget{level-4-heading}{%
\paragraph{Level 4 heading}\label{level-4-heading}}
\hfill
Lorem ipsum dolor sit amet.
This LaTeX looks awful, but if you don’t need to keep or share the LaTeX
source it does what you probably want: a space between the level 4
heading and the paragraph after it equal to the space between a level 3
heading and the paragraph after it.
Here is how it works: since a \hfill on a line on its own is about as
close as you can get to an empty paragraph in LaTeX you get a first
paragraph — the one running in with the heading — containing only
horizontal white space until the end of the line, and then immediately
after a new paragraph — the actual first paragraph after the heading —
with just a normal paragraph space between it and the heading. This
probably also upsets LaTeX’s idea about what a \paragraph should be
like as little as possible.
The “manual” way to do this is as follows:
#### Level 4 heading
````{=latex}
\hfill
````
Lorem ipsum dolor sit amet.
This uses Pandoc’s relatively new raw markup syntax — the “code block”
is actually a raw LaTeX block — but it looks even more awful than the
resulting LaTeX source! It is also a tedious chore to have to insert
this after every level 4 heading. In other words you want to insert that
raw LaTeX automatically, and that can be done with a Lua filter:
--[======================================================================[
latex-h4-break.lua - Pandoc filter to get break after a level 4 heading.
Usage:
$ pandoc --lua-filter latex-h4-break.lua input.md -o output.pdf
--]======================================================================]
-- create it once, use it many times!
local hfill_block = pandoc.RawBlock('latex', '\\hfill')
function Header (elem)
if 4 == elem.level then
return { elem, hfill_block }
else -- ignore headings at other levels!
return nil
end
end
However you can also do a simple LaTeX hack in a header-includes
metadata block to get the same effect:
---
header-includes:
- |
``` {=latex}
\let\originAlParaGraph\paragraph
\renewcommand{\paragraph}[1]{\originAlParaGraph{#1} \hfill}
```
---
#### Level 4 heading
Lorem ipsum dolor sit amet.
This works by first creating an “alias” of the \paragraph command and
then redefining the \paragraph command itself, using the alias in the
new definition so that now wherever the LaTeX source created by Pandoc
contains \paragraph{Foo} it is if it instead had contained
\paragraph{Foo} \hfill which does what we want with zero extra
dependencies! (In case you wonder the wacky spelling of the “aliased”
command is to minimize the risk that it collides with anything which
already exists, since the TeX \let command doesn’t check for that. We
certainly don’t want to overwrite any existing command!)
NOTE: If you really should want more or less space than a normal
paragraph break after the heading just add an appropriate \vspace
command after the \hfill: \hfill \vspace{-0.5\parskip}.
Shifting Headers
Arguably the best way to solve this would be to avoid the problem altogether by shifting what a level 4 header corresponds to. The default for pandoc is to use \section commands for 1st level and \paragraph for 4th level headers. This can be altered via the --top-level-division parameter:
--top-level-division=[default|section|chapter|part]
Treat top-level headers as the given division type in LaTeX [...] output. The hierarchy order is part, chapter, then section; all headers are shifted such that the top-level header becomes the specified type. The default behavior is to determine the best division type via heuristics [...]
So with --top-level-division=chapter, a 4th-level header would be generated via the \subsubsection command.
Styling via LaTeX
If this is not an option, the next best way is to configure the layout of the corresponding LaTeX command: for level-four headers, this is \paragraph by default. The following methods are taken from TeX StackExchange answers.
Please also check the answer by bpj, which is much simpler than what's proposed below.
Default document-classes
The default way would be to configure \paragraph via the titlesec package. We can use the header-includes metadata field for this, which pandoc will include in the intermediate LaTeX document.
---
header-includes: |
``` {=latex}
\usepackage{titlesec}
\titlespacing*{\paragraph}{0pt}{1ex}{-\parskip}
\titleformat{\paragraph}[hang]
{\normalfont\bfseries}
{}
{0pt}
{}
```
---
KOMA document-classes
Using titlesec won't work properly for documents using KOMA classes (like scrartcl), as KOMA has it's own ways of doing things. For these, use this alternative snippet:
---
documentclass: scrartcl
header-includes: |
``` {=latex}
\makeatletter
\renewcommand\paragraph{\#startsection{paragraph}{4}{\z#}%
{-3.25ex \#plus -1ex \#minus -0.2ex}%
{0.01pt}%
{\raggedsection\normalfont\sectfont\nobreak\size#paragraph}%
}
\makeatother
```
---
I am not sure, why, but this works for me:
Put $\ \\ $ in the first line after your #### headline