Tufte-LaTeX + MultiMarkdown

1,038 views
Skip to first unread message

Ewan

unread,
Jan 20, 2012, 9:16:33 AM1/20/12
to tufte...@googlegroups.com
As requested, some details on how I'm using Tufte-LaTeX with MultiMarkdown (MMD). (Warning: I'm no expert, and I use a Mac. This will work differently on Windows). 

MMD is described on the website as:

...a tool to help turn minimally marked-up plain text into well formatted documents, including HTML, PDF (by way of LaTeX), OPML, or OpenDocument (specifically, Flat OpenDocument or ‘.fodt’, which can in turn be converted into RTF, Microsoft Word, or virtually any other word-processing format).

More simply, you write in a very lightweight, readable syntax, which is then converted to LaTeX/RTF. It works very well with Scrivener.

LaTeX output works using metadata, which is placed at the top of each document. For example:

\input{mmd-tufte-header}
\def\latexmode{memoir}
\input{mmd-tufte-book-begin-doc}
\chapter{Chapter Title}

The \input commands refer to files in your "~/Library/texmf/" folder. For Tufte-LaTeX, I use the following files:
At the end of the document, I add (or rather, Scrivener adds for me) "\input{mmd-tufte-footer}" which points to:
These files are a work in progress – I've pieced them together from the Tufte-LaTeX example files. I'll probably need to add packages/customisations as I near completion. 

Some points on using MMD with Tufte-LaTeX:
  • I write everything in Scrivener, so rarely see any LaTeX code. 
  • Citations are written in the MMD syntax, which gets converted to LaTeX (natbib) later.
  • Equations are written in MMD.
  • Standard images (i.e. \begin{figure}) are written in MMD, as is all formatting (bold/italics/quotes).
  • Footnotes are written in MMD, which get converted to LaTeX footnotes, which (in Tufte-LaTeX) become sidenotes. This is fine, so long as you don't need to adjust the position of a side note. 
For anything complicated (i.e. where I need to edit the LaTeX code), I just insert LaTeX code directly into Scrivener. By surrounding text with the HTML comment tags "<!--" and "-->" it is ignored by the MMD parser, and so gets passed straight through to the LaTeX document. 

I used this quite a lot, particularly with Tufte-LaTeX:
  • Almost all images (i.e. marginfigure, or figure*)
  • A lot of tables (MMD does have a table syntax, but it's limited)
  • Any time I need to adjust the placement of something (e.g. a marginfigure or caption).
---

That's about it. Any questions, ask away.

Ewan
--







 


 

Aaron Morton

unread,
Jan 22, 2012, 3:10:43 AM1/22/12
to tufte-latex
Hi Ewan,
I'm also building a tufte-latex book via MMD, however I've dropped
down to the level of MMD to HTML to LaTeX via XSLT so I can control
the latex output see https://github.com/fletcher/MMD-Support

These are some of the changes I made...

* change citep to cite for citations.
* change figure template, I'm using the reference style of images and
if I add a margin attribute I create a \begin{marginfigure} otherwise
I use a standard \begin{figure}. When I get to it I'll also make it
use \begin{figure*} if the img has a fullwidth attribute.
* change img template to remove the default width / height.
* change cross references from autoref to pageref
* add anchor rule to build cross references for image refs correctly.
* I'm using BibTex citations.
* I'm using MMD to define a glossary and building the LaTeX glossary

I'm writing with Text Mate and then building the book as follows:

# merge the different files together
mmd_merge.pl content/index.md

# build the HTML
multimarkdown Book.md > Book.xhtml

# make the latex
xsltproc -nonet -novalid tufte-book.xslt Book.xhtml > Book.tex

# first pass with LaTeX not totally sure I need this but it works for
now.
pdflatex Book.tex

# Make the BibTeX files
bibtex Book

# Make the glossary

makeglossaries Book

# Two runs of latex to get the final output.

pdflatex Book.tex &&
pdflatex Book.tex &&

It's a little more involved that was probably necessary but I now have
a pretty good handle on how to control the latex output. There are a
few issues I've still to test out such as tables, but it's getting
there.

Cheers
Aaron


On Jan 21, 3:16 am, Ewan <ewanc...@gmail.com> wrote:
> As requested, some details on how I'm using Tufte-LaTeX with MultiMarkdown
> (MMD). (Warning: I'm no expert, and I use a Mac. This will work differently
> on Windows).
>
> MMD is described on the website <http://fletcherpenney.net/multimarkdown/>as:
>
> ...a tool to help turn minimally marked-up plain text into well formatted
> documents, including HTML, PDF (by way of LaTeX<http://en.wikipedia.org/wiki/LaTeX>
> ), OPML <http://en.wikipedia.org/wiki/OPML>, or OpenDocument (specifically,
> Flat OpenDocument <http://en.wikipedia.org/wiki/OpenDocument> or ‘.fodt’,
> which can in turn be converted into RTF<http://en.wikipedia.org/wiki/Rich_Text_Format>,
> Microsoft Word, or virtually any other word-processing format).
>
> More simply, you write in a very lightweight, readable syntax, which is
> then converted to LaTeX/RTF. It works very well with Scrivener<http://www.literatureandlatte.com/scrivener.php>
> .
>
> LaTeX output works using *metadata*, which is placed at the top of each
> document. For example:
>
> \input{mmd-tufte-header}
> \def\latexmode{memoir}
> \input{mmd-tufte-book-begin-doc}
> \chapter{Chapter Title}
>
> The \input commands refer to files in your "~/Library/texmf/" folder. For
> Tufte-LaTeX, I use the following files:
>
>    - ~/Library/texmf/tex/latex/mmd/mmd-tufte-header.tex<http://pastie.org/pastes/3219065/text>
>    - ~/Library/texmf/tex/latex/mmd/mmd-tufte-book-begin-doc.tex<http://pastie.org/pastes/3219074/text>
>
> At the end of the document, I add (or rather, Scrivener adds for me)
> "\input{mmd-tufte-footer}" which points to:
>
>    - ~/Library/texmf/tex/latex/mmd/mmd-tufte-footer.tex<http://pastie.org/pastes/3219086/text>
>
> These files are a work in progress – I've pieced them together from the
> Tufte-LaTeX example files. I'll probably need to add
> packages/customisations as I near completion.
>
> Some points on using MMD with Tufte-LaTeX:
>
>    - I write everything in Scrivener, so rarely see any LaTeX code.
>    - Citations are written in the MMD syntax<http://pastie.org/pastes/3219101/text>,
>    which gets converted to LaTeX (natbib) later.
>    - Equations are written in MMD.
>    - Standard images (i.e. \begin{figure}) are written in MMD, as is all
>    formatting (bold/italics/quotes).
>    - Footnotes are written in MMD, which get converted to LaTeX footnotes,
>    which (in Tufte-LaTeX) become sidenotes. This is fine, so long as you don't
>    need to adjust the position of a side note.
>
> For anything complicated (i.e. where I need to edit the LaTeX code), I just
> insert LaTeX code directly into Scrivener. By surrounding text with the
> HTML comment tags "<!--" and "-->" it is ignored by the MMD parser, and so
> gets passed straight through to the LaTeX document.
>
> I used this quite a lot, particularly with Tufte-LaTeX:
>
>    - Almost all images (i.e. marginfigure, or figure*)
>    - A lot of tables (MMD does have a table syntax, but it's limited)
>    - Any time I need to adjust the placement of something (e.g. a

Ewan

unread,
Jan 24, 2012, 10:17:24 AM1/24/12
to tufte...@googlegroups.com
Hi Aaron,

Thanks for that – very interesting. I remember using XSLT from the days of MMD2, but since using MMD3 have forgotten all about it. 

If Scrivener didn't exist, I'd probably use a system much like yours – I love TextMate (and wrote a previous thesis in LaTeX with this), but would miss the flexibility of Scrivener – e.g. dragging and dropping sections, easily reordering etc. Particularly in the early stages of writing. 

Quick question: how do you break down the book into MMD files? One per chapter, one per section? Or smaller? 

Also: 

* change figure template, I'm using the reference style of images and
if I add a margin attribute I create a \begin{marginfigure} otherwise
I use a standard \begin{figure}.  When I get to it I'll also make it
use  \begin{figure*} if the img has a fullwidth attribute.

Does this mean you can insert figures using MMD syntax, and have them converted to either marginfigure/figure*/figure, depending on the attributes? And are these the same attributes used to set titles/width in MMD figures (i.e. the reference style syntax?). 

If so, that's pretty great. Inserting bits of LaTeX directly into Scrivener is quick and easy, but it means I can't export to anything but LaTeX (since the figures/tables/etc get escaped). I'm guessing it would be possible to write a XSLT template for HTML output of marginfigure/figure* as well? 

(That is, until someone writes Tufte-HTML). :-)

Thanks!

Ewan
--


Ewan

unread,
Jan 24, 2012, 10:26:20 AM1/24/12
to tufte...@googlegroups.com
EDIT: Just read your post on the MMD forum – it sounds like you're already working towards a Tufte-HTML-like system. 

The ability to output to either ePub or LaTeX/PDF would be great. I hadn't thought of that before.

Right, time to start reading up on XSLT :-)

David Garbutt

unread,
Jan 24, 2012, 10:42:31 AM1/24/12
to tufte...@googlegroups.com, tufte...@googlegroups.com
Hi
>(That is, until someone writes Tufte-HTML). :-)

I am holding out for Tufte - iBook Author ;-)

Dave


Sent from my iPhone 4

Aaron Morton

unread,
Jan 25, 2012, 12:41:09 PM1/25/12
to tufte-latex
> Does this mean you can insert figures using MMD syntax, and have them
> converted to either marginfigure/figure*/figure, depending on the
> attributes? And are these the same attributes used to set titles/width in
> MMD figures (i.e. the reference style syntax?).

Yes it does. It's a problem for tables because they do not accept
attributes.

My current experiment is to use html / xml comments to pass directives
to the xslt. For example
if I put this <!-- margin --> in the caption for a table i put the
table in the margin. It's a bit hacky but
should let me do things like push side notes up or down.

So far it's just broken up one file per chapter, and files for the
image list, bibtex glossary etc.
The mmd_merge utility does not handle multi level merges so I can only
have one index file.

Cheers


On Jan 25, 4:17 am, Ewan <ewanc...@gmail.com> wrote:
> Hi Aaron,
>
> Thanks for that – very interesting. I remember using XSLT from the days of
> MMD2, but since using MMD3 have forgotten all about it.
>
> If Scrivener didn't exist, I'd probably use a system much like yours – I
> love TextMate (and wrote a previous thesis in LaTeX with this), but would
> miss the flexibility of Scrivener – e.g. dragging and dropping sections,
> easily reordering etc. Particularly in the early stages of writing.
>
> Quick question: how do you break down the book into MMD files? One per
> chapter, one per section? Or smaller?
>
> Also:
>
> * change figure template, I'm using the reference style of images and
>
> > if I add a margin attribute I create a \begin{marginfigure} otherwise
> > I use a standard \begin{figure}.  When I get to it I'll also make it
> > use  \begin{figure*} if the img has a fullwidth attribute.
>
> Does this mean you can insert figures using MMD syntax, and have them
> converted to either marginfigure/figure*/figure, depending on the
> attributes? And are these the same attributes used to set titles/width in
> MMD figures (i.e. the reference style syntax?).
>
> If so, that's pretty great. Inserting bits of LaTeX directly into Scrivener
> is quick and easy, but it means I can't export to anything *but* LaTeX
Reply all
Reply to author
Forward
0 new messages