Wednesday, 8 July 2015

Tufte-LaTeX

Edward Tufte is well known for his work on textual and graphic presentations. His books, starting with The Visual Display of Quantitative Information are written with a very specific style, particularly in the way the pages are organised. Tufte uses wide margins which enforce the writing of side nodes.
For users of LaTeX there is a very good package called tufte-latex for emulating this style. I used this for the writing of the Privacy Engineering book [1], as an example page below shows:
Extract from book: Privacy Engineering -
showing the Tufte style of page layout

There is a Google group for the discussion of the tufte-latex package, but I'll reproduce here my experiences of using this package so maybe a wider audience gets to know about this and how they might too use this excellent LaTeX package.

Originally written 20 July 2014, tufte-latex Google Group

Just a few experiences on self-publishing and the Tufte-LaTeX style - I noticed a few questions and after going through this process successfully (yay!) I'll offer some thoughts here.

Firstly, I looked at a number of self-publishers, Lulu, CreateSpace etc. Of these CreateSpace gives the best options from book styles (colour, B/W, sizes), ISBN options, marketing etc. YMMV of course.

In the end I chose a 7x9 inch format for an academic text book, B/W printing on white paper. CreateSpace assigned the ISBN and deal with the purchasing and printing, plus the sales channels which are fairly extensive. The main problem is that you don't get an editor nor deadlines :-)   So spelling checking is going to be your responsibility. You also don't get an advance from the publisher either, so no Ferrari while you complete your masterpiece....

My set up is as follows:
  • Sublime and vi editors
  • Bibtex
  • Pdflatex
  • Microsoft Visio Professional
running on Windows, MacOSX, Linux as necessary. Whether you like Visio or not, it is the best diagramming tool. You might also need Gimp for cropping pictures.

Actually, running LaTeX with the Tufte style is no more difficult than anything else in LaTeX but there are a few considerations:

  1. Tufte gives ample room for side notes - great for references and additional comments, marginalia etc

  2. You can no longer say things like "as demonstrated in [34]" because the reference number appears as a superscript. This changes the style of sentence in that you must explain what you're talking about instead of relying on the reader referring to the reference.

  3. Diagrams:  be very careful with figure* and figure.  Most of the time  figure  is fine and try to keep the diagram within the margins of the main body of text. Sometimes it is necessary to use the full width, but sparingly IMHO

  4. Tables: I used the full width unless the table was particularly simple.  So  table*  for most.

  5. Labels: Didn't use as \ref{label name} doesn't give the section number. I suppose you could reference back to page, but (see #2) you can change your style of writing to make everything stand-alone. Actually I did refer back to figures and tables as necessary.

  6. Margins... I actually hacked tufts-common.def (see below)

  7. Tables again: see below for the Latex formatting not to use vertical lines - works well.

  8. Diagrams again: 300dpi minimum. I actually used 600dpi PNG files for inclusion in the text. If you export from PowerPoint this is going to be a big problem, but there are instructions to force PPT to export at 300dpi by adding things to the registry (fun!)

  9. Justified text for the body and sans serif sidenotes looks great!

I should have used \geometry but this was my method. I added between the A4paper and B5paper sections to tufte-common.def:

%%%%%%%%%%%%%%%%% IAN 7.44 by 9.69 inches
\newboolean{@tufte@ianpaper}
\DeclareOptionX[tufte]{ianpaper}{\setboolean{@tufte@ianpaper}{true}}

Then later in the file (Search for a4paper and put it after there):

%%%%%%%%%%%%%%%%%%%%IANPAPER DEFINITION
%%%% 7.44in x 9.69in  == 18.898cm x 24.613 cm
%Another modification for 300 page manuscript on CreateSpace
\ifthenelse{\boolean{@tufte@ianpaper}}
  {\geometry{paperwidth=7.44in,paperheight=9.69in,left=0.75in,top=20mm,bottom=20mm,headsep=2\baselineskip,textwidth=3.86in,marginparsep=0.28in,marginparwidth=1.8in,textheight=190\baselineskip,headheight=\baselineskip}}
  {}

You'll need to play with the margins to get CreateSpace's previewer to stop reporting errors regarding the sizes and gutter etc. But you HAVE to do this anyway to get the book published regardless of whether you using Word, LaTeX etc. Now you can use the above as a document style, ie:

\documentclass[10pt,ianpaper,sfsidenotes,twoside,justified]{tufte-book}

When working with margins the showframe package is very, very helpful:

\usepackage{showframe}


Tables

 You need to work with the p{size} options quite a bit to get these perfect...lots of LaTeX recompiling sorry. For example, the following extract gives an idea:

\begin{table*}
\small
    \begin{tabular}{  p{2.2cm}  p{2.2cm}  p{4.2cm}  p{1.5cm}  p{2.9cm} }
    \hline
 & \textbf{Adult} &  \textbf{Child} &  \textbf{System} &  \textbf{External} \\ \hline\hline
Collection & Allowed, with consent & As per COPPA, but generally not allowed & Allowed & As per agreements \\ \hline
    \end{tabular}
   \caption[][0.5cm]{Example Policy Level Provenance Classification Requirements}
\end{table*}

I found that a double line after the title and single horizontal lines elsewhere looks good IMHO

Citations, Sidenotes, Captions and Marginalia:

This is going to be the biggest headache!!!

Don't fiddle with the layout of these until you've reached your final, final draft. I noticed that various PDF views won't show text outside the margins so things seem to disappear only to reappear in CreateSpace's previewer which tells you about these things. Once the text is finalised then work with moving these elements up and down to make the fit within the vertical margins of the page. Much trial and error. Note that captions take 3 parameters, sidenotes just 2 ... this caught me a few times!

Also, sometimes text in \url{} or unsplittable text exceeds the horizontal margins...YMMV and you'll have to find a work around. Again for these aspects the showframe package is very helpful.

TOC, Indexes:

ToC depth should be 1 otherwise the ToC becomes too long, even though I used subsections, these don't appear in the ToC. The list of tables and figures doesn't follow the ToC style, but given the length of the latter in my case I'm pretty happy about this! This could be moved to the back matter if you want, depending upon what you're writing of course.

makeindex for some reason did not work - I could not get indexes to work at all... :-(   No idea why but in the end writing was more important than typesetting and indexes at that stage.

Font size:

I used \small with all the tables but didn't see a huge difference in font size. \tiny works, but that way too small. Otherwise things like \Huge etc work fine. Don't forget \normalsize after you've changed the font size temporarily :-)

So, overall Tufte-LaTeX is fairly easy to use with CreateSpace...thanks to all who gave help and worked on this style: it really does look fantastic in print! If you want to see the book you can go here: www.privacyengineeringbook.net   and navigate to Amazon - I think there might be a preview available. However the conversion to Kindle is always a little problematical from what I've heard but then again not a lot you can do about that. Kindle doesn't like tables and sometimes the sidenotes get mixed in the text.

My preamble looks something like this:

Note I have two documentclass lines so I can swap between A4 for printing on rather obstinate HP laser printer and the 7x9 for the real version. Showframe is commented out here. A few other things I found on these groups such as the paragraph indentations etc. I changed the parskip here.
TOC depth I set to 1 otherwise the ToC becomes too long.

\documentclass[10pt,ianpaper,sfsidenotes,twoside,justified]{tufte-book}
%\documentclass[10pt,a4paper,sfsidenotes,twoside]{tufte-book}

\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{microtype}

%\usepackage{showframe}

\DeclareGraphicsExtensions{.pdf,.png,.jpg,.PNG}

%package to get copyright symbol
\usepackage{textcomp}

\makeatletter
% Paragraph indentation and separation for normal text
\renewcommand{\@tufte@reset@par}{%
  \setlength{\RaggedRightParindent}{1.0pc}%
  \setlength{\JustifyingParindent}{1.0pc}%
  \setlength{\parindent}{0pt}%
  \setlength{\parskip}{14pt}%
}
\@tufte@reset@par

% Paragraph indentation and separation for marginal text
\renewcommand{\@tufte@margin@par}{%
  \setlength{\RaggedRightParindent}{0.5pc}%
  \setlength{\JustifyingParindent}{0.5pc}%
  \setlength{\parindent}{0pt}%
  \setlength{\parskip}{6pt}%
}

\makeatother

\setcounter{tocdepth}{1}

\renewcommand{\baselinestretch}{0.925}

%----------------------------------------------------------------------------------------
% BOOK META-INFORMATION
%----------------------------------------------------------------------------------------

\title{Privacy Engineering} % Title of the book
\author[I. Oliver]{Ian Oliver} % Author

%----------------------------------------------------------------------------------------
\begin{document}
%----------------------------------------------------------------------------------------
\frontmatter

\input{./FrontMatter/title}
\input{./FrontMatter/copyright}
\input{./FrontMatter/dedication}

\tableofcontents \thispagestyle{empty}
\listoffigures \thispagestyle{empty}
\listoftables \thispagestyle{empty}


%----------------------------------------------------------------------------------------
\mainmatter
\input{./introduction/introduction}
\input{./CaseStudy/casestudy}
\input{./privacyEngineeringProcess/privacyengineeringprocess}
\input{./DataFlowModelling/dataflowmodelling}

%lots of skipped chapters!!

\backmatter
\bibliography{privacyrefs}
\bibliographystyle{plainnat}
\input{./BackMatter/bio}
\end{document}



* * *

References

[1] Ian Oliver. Privacy Engineering: a data flow and ontological approach. CreateSpace Independent Publishing.

2 comments:

healthfully said...

Hi Ian: I saw this post on the Tufte-LateX Google group and asked you a question there, but since nobody has responded and it has been 4 days, I thought I'd try you here:

I want to print on A5, which this is exactly half of A4, and is a nice handy format that I like for practical and aesthetic reasons. So, I define in the document class options a5paper and the typesetting is done accordingly, and differently than it is when the paper is specified as A4. The result is a slightly taller spacing between lines and slightly larger letters than if I print the A4 version on A5 paper just using a shrinking factor to fit the page. This is an improvement, of course, but the size of the letters is still much too small to be easily readable.

Therefore, what I want to know is how I can increase a little more the size of everything that relates to the size of the letters and spacings used in the typesetting so that it looks the same but simply larger, without discordance between the size or spacing of different elements (text, captions, headings, etc) in the book. Can you help me in this matter?

Ian Oliver said...

Hi,

I'd love to help, but really I'm not a LaTeX expert. Your question relates more to how the a5paper class works rather than Tufte-LaTeX; and my solution to the paper sizing there is pretty ugly.

You'd be better off posting to a general purpose LaTeX group,

t.

Ian