Cross-referencing panel-tabset in Quarto - quarto

Is there a way of cross-referencing tabs names in panel-tabset in Quarto?
I have tried with section but it doesn't work.
::: panel-tabset
## A {#sec-inst1}
## B {#sec-inst2}
:::
If a then see #sec-inst1 else see #sec-inst2

Related

With quarto how can I right-left center align (justify) contents within a column in a two column display

I have a two column display in quarto. What do I add to right-left center (justify) content within each of the columns? Here is the basic code:
---
title: "uncentered"
---
:::: {.columns}
::: {.column width="50%"}
content
x
content
:::
::: {.column width="50%"}
y
content
y
:::
::::
From the pandoc docs I see I can use align=center in beamer but I just want a basic html page.
If you want to tweak things in html, you can use css rules as a last resort.
Try this
---
title: "uncentered"
format: html
engine: knitr
---
```{css echo=FALSE}
.column {
text-align: center;
}
```
:::: {.columns}
::: {.column width="50%"}
content
x
content
:::
::: {.column width="50%"}
y
content
y
:::
::::
Also take note of that engine: knitr in yaml. Since Here the very first thing was used a css code, Quarto will try to render this file using jupyter engine. So I have specified engine: knitr just to be in a safe side.

Pandoc Column Width for Twocolumn not working

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}

How to remove number from toc title with pandoc+beamer

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}

Pandoc-generated PDF: Change list numbering style

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.

Slides with Columns in Pandoc

I would like to have code and an image side-by-side in a Beamer slide.
In LaTeX I would do this with columns. I would like to use markdown within the column structure.
\begin{columns}
\column{.5\textwidth}
~~~~~~~~Python
>>> some python code
~~~~~~~
\column{.5\textwidth}
![](A_generated_image.pdf)
\end{columns}
Unfortunately Pandoc doesn't process the markdown within the \begin{columns} and \end{columns} statements. Is there a way around this?
Is there a way to use markdown within inlined LaTeX?
Is there a pure markdown solution?
Current versions of pandoc (i.e., pandoc 2.0 and later) supports fenced divs. Specially named divs are transformed into columns when targeting a slides format:
# This slide has columns
::: columns
:::: column
left
::::
:::: column
right
::::
:::
Pandoc translates this into the following LaTeX beamer code:
\begin{frame}{This slide has columns}
\protect\hypertarget{this-slide-has-columns}{}
\begin{columns}[T]
\begin{column}{0.48\textwidth}
left
\end{column}
\begin{column}{0.48\textwidth}
right
\end{column}
\end{columns}
\end{frame}
This is simple and has the additional advantage of giving similar results when targeting other presentational formats like reveal.js.
More than two columns work out of the box for Beamer output. Powerpoint, however, only supports two columns. For reveal.js, the widths of three or more columns must be given explicitly:
::: columns
:::: {.column width=30%}
left
::::
:::: {.column width=30%}
middle
::::
:::: {.column width=30%}
right
::::
:::
The problem is that pandoc ignores markdown if it finds a \begin{}. An alternative is to edit the beamer template and add the following:
\newcommand{\columnsbegin}{\begin{columns}}
\newcommand{\columnsend}{\end{columns}}
And write it like this:
\columnsbegin
\column{.5\textwidth}
~~~~~~~~Python
>>> some python code
~~~~~~~
\column{.5\textwidth}
![](A_generated_image.pdf)
\columnsend
I hope still valuable. I made a Pandoc filter in Python to put columns easily, so you can write your presentations in this way:
# Hello World
[columns]
[column=0.5]
~~~python
if __name__ == "__main__":
print "Hello World"
~~~
[column=0.5]
This is how a "Hello World" looks like in Python
[/columns]
that the filter will convert each markup to \begin{columns} and \column{.5\textwidth}, so, the document above will turn in
\begin{frame}[fragile]{Hello}
\begin{columns}
\column{0.5\textwidth}
\begin{Shaded}
\begin{Highlighting}[]
\NormalTok{some python code}
\end{Highlighting}
\end{Shaded}
\column{0.5\textwidth}
Hello World
\end{columns}
\end{frame}
The code filter is here
import pandocfilters as pf
def latex(s):
return pf.RawBlock('latex', s)
def mk_columns(k, v, f, m):
if k == "Para":
value = pf.stringify(v)
if value.startswith('[') and value.endswith(']'):
content = value[1:-1]
if content == "columns":
return latex(r'\begin{columns}')
elif content == "/columns":
return latex(r'\end{columns}')
elif content.startswith("column="):
return latex(r'\column{%s\textwidth}' % content[7:])
if __name__ == "__main__":
pf.toJSONFilter(mk_columns)
If you never use a pandoc filter, just save the filter to the same document location as columnfilter.py (or other name you want) and run
pandoc -t beamer --filter columnfilter.py yourDocument.mkd
And enjoy!
Beamer Specific Answer. I ran across a solution when attempting to add multiple columns for Pandoc in a regular document. It works here as well, though it does constrain you to Beamer; though that is your use case.
In the slide deck, insert once:
---
header-includes:
- \newcommand{\hideFromPandoc}[1]{#1}
- \hideFromPandoc{
\let\Begin\begin
\let\End\end
}
---
Then add content thus:
\Begin{columns}
\Begin{column}{0.3\textwidth}
Res ipsum loquiter, sed in inferno decit?
\End{column}
\Begin{column}{0.3\textwidth}
Res ipsum loquiter, sed in inferno decit?
\End{column}
\Begin{column}{0.3\textwidth}
Res ipsum loquiter, sed in inferno decit?
\End{column}
\End{columns}
Creating the "hideFromPandoc" command lets you insert begin/end statements throughout without depriving you of markdown in the block.
Fenced Div Answer. There's an answer above that refers to fenced divs. I commented that the answer only works with two columns. It breaks down with more. Here is how that answer works with multiple divs:
::: {.columns}
:::: {.column width=0.3}
Test
::::
:::: {.column width=0.3}
Test
::::
:::: {.column width=0.3}
Test
::::
:::
To get this answer, I had to look at the commit that added the column feature specifically.
You could use FletcherPenney MultiMarkdown which can process markdown to LaTeX/Beamer. Compared to Pandoc, MultiMarkdown has not so many features. However, especially when working with LaTeX it has the advantage that you can embed LaTeX code directly into the Markdown in HTML comments.
Your code would look like this:
<!-- \begin{columns} -->
<!-- \column{.5\textwidth} -->
>>> some python code
<!-- \column{.5\textwidth} -->
![](A_generated_image.pdf)
<!-- \end{columns} -->
For me this solution works fine. With a good editor (e.g. Scrivener, Sublime Text) you can write the latex code without all the comments and find/replace them after editing. In addition, the Metadata support in Multimarkdown is much more flexible, so that it is easier to customize presentations.
In the meantime, I hope that the Pandoc team provides a solution to this problem. I think there are some users who would like to embed small LaTex code particles throughout their markdown documents without having them converted/escaped.
You can use MultiMarkDown comments ( "<!-- Your LaTeX Code inside -->" ) with Pandoc when you enclose the Pandoc command in which you transform your markdown to LaTeX with two sed commands.
In the first sed run, you change the MultiMarkDown comments to "\verb+AAAAAAALaTeX-StuffZZZZZZ+". Then you transform to LaTeX with Pandoc as usual, everything inside "\verb+AAAAAAALaTeX-StuffZZZZZZZ+" is left alone. Then you run sed on the TeX-File and delete the "\verb+AAAAAAA" and "ZZZZZZ+" unfolding your LaTeX code.
The first sed command line before the Pandoc transformation could look like this:
sed -E -e "s/<\\!--(.+)--\\>/\\\\verb\+AAAAAAA\1ZZZZZZZ\+/g " \
source.md > source.i.md
Then use Pandoc on source.i.md as usual to create source.tex. Second sed run like this:
sed -E -e "s/\\\\verb\+AAAAAAA(.+)ZZZZZZZ\+/\1/g" -i "" source.tex
I automated everything in a Makefile so that I can make more changes e.g. to table definitions in one step. On first glance this approach works fine (tested it on column definitions with the beamer class).
With this little sed scripts, you can use all the nice things from Pandoc. You need only to mmd-comment those TeX and LaTeX commands which become either escaped or enclose larger parts of your Markdown.

Resources