JunoLab / Weave.jl

Scientific reports/literate programming for Julia
http://weavejl.mpastell.com
MIT License
821 stars 94 forks source link

LaTeX (text mode) commands #459

Open EvoArt opened 2 years ago

EvoArt commented 2 years ago

Hi there Is it possible to iput text in a .jmd and have it included verbatim in a generated .tex file? e.g. I use a custom template with tufte.sty and it would be great to be able to type \sidenote{some cool fact} and have the side note appear in my pdf.

NoelAraujo commented 2 years ago

I would love to see 'Tufte style' listed in list_out_formats, but I imagine that Julia Mardown needs to support it first (?)

Maybe someone knows how to create Tufte with Weaver.jl could post a minimal working example here.

EvoArt commented 2 years ago

I have a custom template like this

\documentclass{tufte-handout}

\usepackage{geometry}
\usepackage{lmodern}
\usepackage{sourcecodepro}
\usepackage{amssymb,amsmath}
\usepackage{bm}
\usepackage{graphicx}
\usepackage{microtype}
\usepackage{hyperref}
\usepackage{listings}
\usepackage{color}
\definecolor{lbcolor}{rgb}{1,1,0.95} 
\lstset{frameround=fttt,
    frame=trBL,
    basicstyle=\sourcecodepro\footnotesize,
    upquote=true,
    breaklines=true,
    breakindent=0pt,
    keepspaces=true,
    showspaces=false,
    columns=fullflexible,
    showtabs=false,
    showstringspaces=false,
    escapeinside={(*@}{@*)},
    extendedchars=true,
    backgroundcolor=\color{lbcolor}
}
{{#:tex_deps}}
{{{ :tex_deps }}}
{{/:tex_deps}}
\setlength{\parindent}{0pt}
\setlength{\parskip}{1.2ex}

\hypersetup
       {   pdfauthor = { {{{:author}}} },
           pdftitle={ {{{:title}}} },
           colorlinks=TRUE,
           linkcolor=black,
           citecolor=blue,
           urlcolor=blue
       }

{{#:title}}
\title{ {{{ :title }}} }
{{/:title}}

{{#:author}}
\author{ {{{ :author }}} }
{{/:author}}

{{#:date}}
\date{ {{{ :date }}} }
{{/:date}}

{{ :highlight }}

\begin{document}

{{#:title}}\maketitle{{/:title}}

{{{ :body }}}

\end{document}

and call weave like so

weave("my_doc.jmd", template = "custom.tpl", doctype = "md2pdf")

margin figures can be included:

```julia, fig_env = "marginfigure", fig_pos = "-1cm",fig_cap = "Plot of x and y."
plot(x,y)

Only works if you include fig_pos

Obviously, you need to install tufte.sty for this to work.

Not sure how to do sidenotes, but Julia Markdown would not need to support it. Just needs some way to tell Weave to pass on the raw LaTeX command to pdflatex, I think.