Tufte-LaTeX / tufte-latex

A Tufte-inspired LaTeX class for producing handouts, papers, and books
https://tufte-latex.github.io/tufte-latex/
1.68k stars 300 forks source link

Modernize Tufte-LaTeX #176

Open chriskgrant opened 1 year ago

chriskgrant commented 1 year ago

Hi-- I'm a big fan of this LaTeX class, but it seems that it's been a very long time since it's been updated and it didn't seem to work well with modern TeX engines such as LuaLaTeX and XeLaTeX. I've taken a stab at modernizing the Tufte-LaTeX classes, which I hope will keep them usable into the future.

Here are the changes I've made:

  1. Use the iftex package to determine which TeX engine is running;
  2. Fix handling of fonts and letterspacing under LuaLaTeX and XeLaTeX, which was needed to get the class to work with LuaLaTeX;
  3. Substitute biblatex and biber for natbib/bibtex for making bibliographies; this involved breaking the optional vertical offset argument of the re-defined \cite command, as I couldn't figure out how to get it to work with biblatex;
  4. Add a Makefile for easy testing and installation of the classes.
  5. Under XeLaTeX or LuaLaTeX, use the ETbb typeface (from the etbb package) as the default main font, if it's installed, and TeX Gyre Pagella if not.

I'm new to this, so I'd certainly welcome any feedback.

gbelanger commented 1 year ago

Amazing work!!

andrewufrank commented 1 year ago

I have tried to build a fork with most unmerged pull requests. unfortunately this pull request which i would like very much to integrate causes conflicts with other patches I have integrated. my partially update repository is git@github.com:andrewufrank/tufte-latex-af.git and your patch is in the branch for176. I attempted a merger, but do not understand enough to do it. could you help? any suggestion to what I should include is welcome! thank you! andrew

chriskgrant commented 1 year ago

Hi @andrewufrank. I based the branch for this pull request off of the master branch, so it would be a lot of work to reconcile the commits I've pushed with however many other pull requests you merged first -- and I definitely don't have time to do that 😂. To be honest, this was something of a maintenance pull request that (1) fixed some low-level problems relating to TeX engines and bibliography management, and (2) included a major but non-substantive re-write to fix the code formatting, so you might consider merging this pull request first and then merging in other pull requests with the features you want. But you'll still probably have to address a bunch of conflicts due to the code formatting I did, if nothing else. Good luck!

andrewufrank commented 1 year ago

Thank you for your work and the advice. I started without much knowledge (and still do not have much). I did not understand which patches you had applied. I will try to merge yours first and then see what else I can merge withot too much trouble. I would like - same as you at that time - to have a few things fixed which are pending a long time. i will make my patched version available and hope it will be better than the current unmaintained version. are you aware of some other uptodate fork? Thank for the help!

iandol commented 10 months ago

@chriskgrant — thanks for your updates, lets hope they can get merged! I wondered if you have views on the following:

  1. \autocite is not working by default although we can use \ExecuteBibliographyOptions{autocite=footnote} — but I wondered if it could be added into the template?
  2. Currently longtable table captions are not compatible with Tufte, any idea if this can be added. There is a hack here though it is fragile: https://tex.stackexchange.com/questions/701043/symmetric-tufte-book-with-longtable-captions
hvoss49 commented 9 months ago

All standard cite styles, which are part of the biblatex package, define \autocite. The user should change this only, if a special package did not depend on one of the standard styles, then it should also define \autocite. If not, it looks like a bug ...

iandol commented 9 months ago

All standard cite styles, which are part of the biblatex package, define \autocite. The user should change this only, if a special package did not depend on one of the standard styles, then it should also define \autocite. If not, it looks like a bug ...

The reason I raised the issue was that \autocite was being rendered in-text, not in the margin. Pandoc generates citations using \autocite and so Pandoc output was getting in-text citations by default. For Tufte, there is a need to override the default of the citation style, and at least now these are ending up in the margin. @hvoss49 as I am sure you are more knowledgeable, what is the preferred way to make sure biblatex citations always show in the margin?

hvoss49 commented 9 months ago

As far as I can see, tufte doesn't load biblatex itself, which should be done if someone uses

\documentclass[nobib]{tufte-book}

to prevent loading of natbib. In this case the user has to load biblatex himself. For example:

\documentclass[nobib]{tufte-book}
\usepackage[style=authoryear,autocite=footnote]{biblatex}
\addbibresource{biblatex-examples.bib}
\begin{document}
... 

It would make more sense if tufte-book itself loads biblatex with the autocite=footnote option and leaves the style setting to the user. Predefining also the style with authoryear makes also sense to me, because the standard style numeric cannot be used for nearly all humanities subjects.

chriskgrant commented 9 months ago

@hvoss49 Actually, one of the changes I've made in this PR is to substitute biblatex for natbib/bibtex, so the class will automatically load biblatex (with bibstyle=authoryear and citestyle=authoryear-icomp) unless the nobib option is used. Given this, it makes sense for me for the class to also use autocite=plain for consistency (note that I use plain instead of footnote because I redefined the \cite command to place citations in the margin). What do you think?

However, if someone wanted to use a different citation style, they would have to use the nobib option and then load biblatex with their desired style separately, for example:

\documentclass[nobib]{tufte-book}
\usepackage[style=numeric]{biblatex}
...

I might add a note along these lines in the sample book for documentation purposes.