2

I'm using Markdown to create a PDF via xelatex and pandoc. Here's my command line:

pandoc -s combined.markdown --from markdown+table_captions+auto_identifiers --filter mermaid-filter.cmd --pdf-engine=xelatex -o combined.pdf

My document contains the following table:

Table: Groups and Access Rights - Global

| Group Name                  | Type      | Config / Func   | Default Act | Reqs     | Derog    | ADC      | Haz      | Chg      | BS         | Risks    | MMSP Status |
| :-------------------------- | --------- | --------------- | ----------- | -------- | -------- | -------- | -------- | -------- | ---------- | -------- | ----------- |
| CPxxx Risk Managers         | \gls{ps}  | X               | CPxxx Home  |          |          |          |          |          |            |          |             |
(etc)

It's very wide, so I want to render it in landscape. I've tried using {rotating}, {lscape}, and {pdflscape}, but they all look like this: enter image description here

Is there any way to make this work? Is it something to do with the order of packages?

2

2 Answers 2

2

I found following solution:

---
title: "Doc-Title"
lang: "de"
colorlinks: true
header-includes:
- |
  ```{=latex}
  \usepackage{pdflscape}
  \newcommand{\blandscape}{\begin{landscape}}
  \newcommand{\elandscape}{\end{landscape}}
    ```
...

in your markdown use:

    \blandscape
    
    |header1|header2|header3|
    |:------|:------|------:|
    |LINE1  | VAL 1 |  1.00 |
    |Line2  | val 2 |  2.07 |
    |Line3  | val 3 |  3.14 |
    
    \elandscape
0

You can use LaTeX chunks inside Markdown, but not markdown inside LaTeX.

In the markdown to LaTeX conversion, what it is inside a command argument or an LaTeX environment is simply ignored (On the other hand, note that the Markdown table is converted to a LaTeX longtable, that could not be used in some conditions (e.g., in two columns documents).

One solution could be first export only the Markdown table and then copy & paste (or \input) the LaTeX code (of the longtable only) in the rotating environment.

Other, more convenient, is to write the nesting environment with the Markdown syntax:

---
output:
  pdf_document: default
header-includes:  
- \usepackage{lscape}  
---


::::::::{.landscape data-latex=""}

11 12 13
-- -- --
21 22 23
31 32 33

::::::::

Removing irrelevant code in the LaTeX output, the above should be equivalent to:

\documentclass{article}
\usepackage{lscape,longtable,booktabs}
\begin{document}
\begin{landscape}
\begin{longtable}[]{@{}lll@{}}
\toprule
11 & 12 & 13\tabularnewline
\midrule
\endhead
21 & 22 & 23\tabularnewline
31 & 32 & 33\tabularnewline
\bottomrule
\end{longtable}
\end{landscape}
\end{document}
3
  • Hi, can you explain what the ":::{}" parts do? I've searched around and can't find any documentation on that.
    – muteboy
    Jan 25, 2021 at 19:32
  • They are simply the landscape environment in rmarkdown syntax. See bookdown.org/yihui/rmarkdown-cookbook/custom-blocks.html
    – Fran
    Jan 25, 2021 at 20:48
  • I don't have R or RMarkdown installed, so I think I'll try a different route. Thanks
    – muteboy
    Jan 26, 2021 at 7:08

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.