We are currently planning to migrate to a different platform for the forum. We will announce this fact both here and on Twitter, once we have settled on a solution.

Tufte handout

Is there a way to do Tufte-style documents (Rmarkdown has it
https://rstudio.github.io/tufte/ ) in Zettlr?

I know there's a latex template for it, but if I wanted to do it in
latex, I would just use it directly.

Comments

  • The thing is, if I read it correctly, the RStudio-template also simply uses the tufte template, and all you'd need to do would be to find a way to add the $body$-variable at the right place and use it as a custom LaTeX template. Then it should work

  • Yes, the basic tufte template works. The problem is with margin figures
    and some other advanced formatting features (full width text, etc.)
    RMarkdown has a couple of custom directives like "marginfigure"
    that puts a figure in margin, etc.

    There are some other ways to get this to work, for example using pp preprocessor:
    https://github.com/duzyn/tufte-markdown

    An example for this project to add a margin figure would be:

    !marginnote(From Edward Tufte, !em(Visual Display of Quantitative Information),
    page 92.) !img(Exports and Imports to and from Denmark & Norway from 1700 to
    1780)(img/exports-imports.png)

    I presume this would be the easiest way to add this to Zettlr.

  • RMarkdown has a couple of custom directives like "marginfigure" that puts a figure in margin, etc.

    Hm, these would need to be defined in the template, I suppose

  • Hm, these would need to be defined in the template, I suppose

    They are.

    To answer my own question, I was able to get this to work via 'pp' preprocessing
    or via raw_latex. For example:

    ```{=latex}
    \begin{marginfigure}

    \end{marginfigure}
    ```

  • Ah! That's good to hear; did you then modify the Pandoc command in the settings to run pp beforehand? :)

  • Yes, I modified command. Something like this:

    /pp -pdf \
    -import=tufte-markdown.pp \
    "$infile$" | \
    pandoc --from=markdown+raw_tex \
    --pdf-engine=xelatex \
    --template= \
    --no-highlight \
    --shift-heading-level-by=-1 \
    --metadata=documentclass:tufte-handout \
    --output="$outfile"

    Note I added "raw_tex" tag which allows me to add raw latex. For example:

    ```{=latex}
    \newthought{Some thought}


    ```{=latex} \begin{marginfigure} Blah $x \in [a, b]$ $$\frac{d}{dx}\left( \int_{a}^{x} f(u)\,du\right)=f(x).$$ \end{marginfigure}

    Summary:

    • you can have Tufte-style template if you use either raw latex or use pp preprocessor
    • pp is a bit of a pain to install/compile, but not too bad
Sign In or Register to comment.