31

Background: This question is aimed primarily at those of us who have been using LaTeX for quite some time but feel like they do not have a very "principled understanding" of it even though they would like to (i.e. those of us who want to go from intermediate to advanced but feel lost at sea).

TL;DR: Does anyone know of a course like structure (MOOC or otherwise...Udemy and Coursera have nothing of value) for intermediate LaTeX users to learn LaTeX in a "principled fashion"? Those of you who teach LaTeX at your universities, how are your courses structured (if you don't mind sharing)?


To keep this question relatively short, I'd simply like to say I've been using LaTeX now for a number of years and have never ceased to be amazed by its capabilities and even more so by the incredible support group here on TeX.SE. I've read several of the other questions somewhat related to this:

The frustrating thing is that most educational LaTeX material seems to be geared towards either those who are just starting out or those who are much more advanced. For example, I look at the content of that Udemy course (and this is not meant to be a knock against it) and am rather surprised by the "advanced content" (all things I am fully comfortable with doing and have done before). But I look at something like the computer science behind TeX/LaTeX by Eijkhout and immediately feel a bit out of my depth.

So far my approach to learning has been to simply learn what's necessary as I encounter different problems (and post here on TeX.SE when I can't progress). Even when I have seen questions on here that I feel like I may know how to answer, I never do because I know several of the gurus here have a "proper" way of going about it all. I also know some members teach LaTeX at their universities (egreg and gonzalo come to mind).

In sum, I am eager to learn LaTeX in a "principled way" (understand the code for packages, be able to write my own, etc etc) but am lost as to how to do it effectively without a course like structure. Simply reading through the TeXbook, LaTeX and Friends, The LaTeX Companion, etc. etc. is not really cutting it anymore (it's so easy to get overwhelmed by the sheer volume of different books that one has great difficulty proceeding in a linear fashion). A well-defined structure would help a great deal.

  • 1
    Flagged this to make it community wiki...if it's more appropriate for meta, please let me know and I'll post it there. – Daniel W. Farlow Aug 10 '17 at 1:01
  • 3
    It doesn't seem a Meta question to me. I think this is the correct place where to ask. (BTW, +1). – CarLaTeX Aug 10 '17 at 4:12
  • 10
    The problem with courses beyond 'basic'/'beginners' is always what does one cover: different users have very different ideas of what counts as intermediate. – Joseph Wright Aug 10 '17 at 7:13
  • 2
    I agree with @JosephWright. The intermediate LaTeX courses I've tried to teach in the past had too wide a range of abilities across the participants that it was impossible to pitch it at the right level to all of them, so for my third LaTeX book I marked up basic, intermediate and advanced in the table of contents as a rough guide. – Nicola Talbot Aug 10 '17 at 13:42
  • 4
    Thanks for mentioning my book "The computer science of .... " but that book is not really about LaTeX. It's about the science that lies behind the internals. It's a CS topics course, using TeX/LaTeX as a hook, but it's of basically zero use if you want to learn more LaTeX. – Victor Eijkhout Aug 12 '17 at 0:43
20
+100

The problem: different users have different interests (and needs) and therefore different ideas of what counts as "intermediate" (beyond the basics), as pointed out by Joseph Wright in a comment above. This was perfectly elaborated by Christian Feuersänger in this answer from 2011: he categorized three kinds of things that post-beginner (La)TeX users may like to learn (which I'm rephrasing), and only you can decide what is important to you:

  1. TeX's features for typesetting specifically: the box-glue-penalty model, alignments, a few parameters and features built into the program like \parshape and the like. Basically: viewing TeX's output (each page) as a giant box made up of boxes laid out in sequences vertically (e.g. lines of text) and horizontally (e.g. characters within a line) with appropriate glue between them, and learning how to make a page look like some predetermined ideal you already have in mind.

  2. TeX's facility for programming: the intricacies of macro expansion: what do terms like \xdef, \expandafter, protected and fragile, \csname mean? How do you write macros that do the work you want them to do? How can you use the features provided by expl3 to make this easier?

  3. The package ecosystem: the facilities provided by LaTeX itself, and by the most important of the thousands of packages available on CTAN. For example, LaTeX itself provides features like automatic numbering (you just type \section and somewhere behind the scenes a counter is incremented and it comes out numbered), cross-referencing (\label and \ref), and so on. There are packages for specific fields (mathematics, chemistry, linguistics), for specific languages, for specific kinds of documents (presentations, drawings), etc.


Now the fact is, for most people who are users of LaTeX, the thing that is probably most useful to them, and in that way most worth knowing, is (3). “How to draw X in TikZ” is something about the features present in the TikZ package. The knowledge that package Y exists for drawing chemical diagrams or grammatical parse trees is something specific to the domain you work in. The knowledge that the “recommended” way to set page margins to use package geometry, or whether to use beamer or powerdot or prosper for presentations, or that \usepackage{hyperref} should come towards the end of your list of included packages, are all of this nature.

In short, a lot of this is knowledge about the “state of the world”: about what packages people happen to have written, what features (and bugs!) those packages happen to have, even how good and up-to-date those packages are — all of these are “contingent” and will even change with time. There is no “core” to this, and not necessarily much consistency because they were written by many different people. You can look at the “banner ad” at https://www.ctan.org/pkg to see a bit of the menagerie of packages that exist. This is the core of the difficulty you mention in the question (learn LaTeX in a "principled way" […] great difficulty proceeding in a linear fashion … A well-defined structure would help), and it is unavoidable as far as I can tell.

A post-beginner (“intermediate” or “advanced”) LaTeX course that goes deeper into any of this will be restricted to some people's uses for LaTeX, and possibly go out of date. And yet this is what most people want and need, so you can consider specific books targeting specific users' needs: the linked LaTeX for Administrative Work by Nicola Talbot above (see its table of contents), or Grätzer's More Math into LaTeX (not free, but see what's available on CTAN to get an idea) are particularly good examples of this.


That leaves categories (2) (macros) and (1) (typesetting primitives). Some people, by "intermediate" or "advanced", mean (2): being able to write and understand macros. This is essentially a new way to program, compared to any other form of programming you may be familiar with. See Notes on Programming in TeX for a (very useful) flavour of things. People have written a BASIC interpreter, the incomparable xii.tex, an Othello game (named reverxii as a tribute to the former), a controller for a Mars Rover… so it's definitely possible to do things in it. Much of LaTeX3 work hitherto has apparently gone into expl3 which makes this easier. This is something one can probably pursue, trying harder and harder exercises until they're proficient at writing macros. (I'm not aware of such a book or resource.)

Personally I find programming in macros rather perverse. :-) (Not just xii.tex and the like, but even the code of typical packages, and of LaTeX itself.) Whatever its other merits, TeX does not have a great programming language in it (see the answers to this question). (There are some comments of Knuth indicating this was intentional, but he did not foresee that people would go to great lengths to program in it anyway.) So personally (and this is a minority opinion in the TeX community, perhaps I am even a minority of one, simply out of not having thought this through well enough): I would prefer a style of TeX usage that involves as few macros as possible. (This is not specific to LaTeX: it would apply to ConTeXt, to plain-TeX packages like opmac, probably every way in which TeX is used currently.)

Nevertheless it (proficiency in TeX macros) is something learnable, and may be a concrete answer to your question.


Finally, that leaves (1) (typesetting). At heart TeX has a startlingly simple and unexpectedly versatile model of typesetting: breaking paragraphs into lines using the box-glue-penalty model. It sounds like something that's only about normal paragraphs of text (and that's what it was designed for), but with appropriate choices of your boxes, glues and penalties, you can achieve practically everything you've ever seen in a document typeset with (La)TeX (and more). The power of this model, despite its unifying simplicity (which was something noted by early reviewers of TeX, like Kernighan who worked on troff), was something of a surprise even to Knuth and he says it took him years to learn more and more things that could be done with it. (Of course from a certain perspective you could call these things hacks, but I find them very elegant.)

This is the part I personally am most interested in (somewhat unusually I think); this is also the thing that is directly against LaTeX's philosophy, which is to focus on the content / document structure, and leave the formatting to the packages you use. And if you're happy with that, you probably don't have to learn deeper here (unless you want to write your own packages that provide formatting, and suddenly you have to learn all the things that your packages were helpfully trying to hide from you). If you do want to learn more about what I consider the core of TeX typesetting, I can recommend what I think are the two best resources (even better to learn from than The TeXbook, which you can read next):

  • The book A Beginner's Book of TeX by Seroul and Levy. This is such a lovely book: it is gentle and assumes nothing, focuses on only a subset of TeX, yet everything is introduced so appropriately and made to seem natural (including making some typical mistakes and explaining why they go wrong), that the design of TeX will appear to make sense.

  • The paper Breaking Paragraphs into Lines by Knuth and Plass. A tour de force: discusses the problem, formulates it mathematically, defines desirability criteria, compares approaches, shows the power of this model (lots of sophisticated examples), then goes into the algorithm with its “bells and whistles” before concluding with an inspiring history.

For more on this aspect of TeX you can read The TeXbook, some other stuff that came out of the Stanford TeX project by Knuth and his associates, some talks and articles by Frank Mittelbach, some stuff by people who have written TeX-like or TeX-inspired systems (there are a few in existence, like SILE and Patoline, and a bigger graveyard of unfinished systems but some of whose authors wrote something useful before their projects died), etc.

But I'll say this upfront: even though this is a lot of fun to learn, it won't help you much when actually using LaTeX. Existing packages have reached a power and complexity beyond what you can easily arrive at from first principles (e.g. LaTeX's float/figure placement is implemented entirely in the macro layer). More on this below…


You mentioned

understand the code for packages, be able to write my own, etc etc

This unfortunately will take some work for anything nontrivial, because the entire system isn't set up for you to succeed at it (it optimizes for the end users, not package writers). The macros of LaTeX or major packages tend to be frightfully complicated because they are the outcome of decades (30+ years in LaTeX's case) of development: starting with something simple, they have grown to encompass all conceivable cases, be robust against various failure modes, etc. (Do you want \section{...} to not break when you stick a macro into its argument? Do you want the code of \section to be simple and readable? Pick one.)

Moreover, most packages are written assuming various functionality of other packages (and, if they have something to do with formatting, the exact formatting of other packages), they may use advanced macro techniques to be robust and comprehensive, these macros in turn assume aspects of other packages, etc.

In short, getting from “I know to use a few packages” to “I understand most of the stuff about most packages and if not I can read and understand them, or write my own” (like some of the top users on this site), involves some combination of all of (1), (2) and (3): you need to know how macros work, know what typesetting abilities exist, and both of these for all other packages you use or which typical users may use along with yours. (You can find packages whose documentation mentions “this package has been tested in combination with the following packages…”.)


So to conclude/reiterate: there are these three different categories, and if you really care about all of them (and not how to be a more skilful LaTeX user who knows how to use which packages, which is what is ultimately useful in real life), then you may have to pursue all three in parallel instead of in any structured manner.

My own preference (“learning style” :P) is to learn things bottom-up, from simplest onwards (without caring for utility), and this usually happens to be the historical order too (things generally get more complex with time: they get easier but rarely simpler), so I'd recommend the following path:

  • Learn (or think about) the main reason TeX was written: to set type (in other words: a not horribly inconvenient way to specify how characters should be picked up from certain fonts and placed on a page), the box-glue model, why its macros exist, simple macros (e.g. \def\line{\hbox to\hsize} and \def\centerline#1{\line{\hss#1\hss}}), building up to more complex things like page layout, etc. Learn enough about plain TeX, even if you're not going to use it. (The book I mentioned, by Seroul & Levy, takes basically this approach.) Read The TeXbook. Read historical material from Digital Typography. Skim through early issues of TUGboat.
  • The big jump that happens with LaTeX: look at some of LaTeX source code (open texdoc source2e and jump to a random page), learn whatever you need till it makes sense. :-)
  • Look at some sample packages which interest you, or answers on this site that seem to have hairy code, understand how they work, etc.

This path is of course very different from learning to do useful things with LaTeX, so I won't recommend it to anyone (also I haven't even got far enough in the first step!). Still, this is one approach that may be somewhat “structured” in the sense you mean. In my case, it has led to fewer things I am completely mystified by and feel “out of my depth”: I may not understand everything (or much), but at least now I can usually get some idea of what's going on and get what I'd need to learn first, when looking at any given situation.

  • Very thoughtful answer and greatly appreciated. You mentioned a few things concerning my personal situation that I did not expand on in my original questions (largely to keep it short and more applicable to everyone else), but I have definitely departed from the whole "I want to learn this because it is useful" approach. I want to get into the nitty gritty, but my main issue has been trying to find an entry point that provides some traction (I am more than willing to put in the time...just don't want to waste it unnecessarily). I have all of Knuth's Selected Papers as well as [...] – Daniel W. Farlow Aug 16 '17 at 3:15
  • [...] all of the Computers and Typesetting volumes and the LaTeX Companions volumes as well (along with a smattering of other (La)TeX books. Your answer really helped me get a better sense of how to more effectively use my own resources and possibly adopt a few others to more fruitfully approach my goals. Thanks again for taking the time to write such a thoughtful answer. – Daniel W. Farlow Aug 16 '17 at 3:17
  • 2
    @DanielW.Farlow Look at the package code, but don't assume it is a good way to do it, safe or even sane. It may be. Or it may be not. – cfr Aug 16 '17 at 3:37
  • 2
    @DanielW.Farlow Glad to have typed it all out if someone found it helpful; nice to see someone else similarly curious. :-) (And +1 to what cfr said: package code may be ancient and doing things in bad ways.) I forgot to mention another resource that you may be interested in: this set of videos (classes by Knuth about TeX: the program has changed but some ideas are still relevant) (also this set of videos: autobiography). – ShreevatsaR Aug 16 '17 at 3:45
10

Since you asked how people who teach this in universities structure courses, here's mine. I teach a series of workshops to postgraduate students from all disciplines. (Generally - occasionally, I've taught a group for a particular school.)

The structure is as follows:

I also distribute a bunch of handouts, including a LaTeX 'cheat sheet', list of basic maths stuff etc. (This is all the standard stuff - not by me.)

  • LaTeX II - intermediate, was a day-long workshop, but recently reorganised into 4 short workshops on particular topics (materials at https://github.com/cfr42/latex-2):

    1. writing macros, classes & packages
    2. bibliographies with Biblatex/Biber
    3. Beamer
    4. float management, graphs of functions and using external data, drawing with TikZ

What these workshops do, for the most part, is say 'here's a useful package or tool and a couple of very simple uses, so you get the general idea'. Each has an appendix with some further information for the students who are racing ahead and directions to further resources. Different students need different things and have different interests, even though these topics are general.

I also provide a handout with package recommendations (general on one side; subject-specific on the other), a Biblatex 'cheat sheet', a font sampler and a list of font packages. (These I had to write as I couldn't find them already done.)

I highly doubt this is what you had in mind, though.

  • Ha, I wondered what cfr meant! Are you related to Sarah Rees? (I stumbled across this posted as I am putting together a course on latex...) – Andrew Aug 15 '18 at 13:31
  • @Andrew Not that I know of, no. 'Rees' is an extremely common name, after all. – cfr Aug 15 '18 at 14:42
0

Joseph Wright has it. LaTeX started out strictly within the university environment for computer science and mathematics streams, but now it's adapted in all directions according to the individual requirement of the user.

I think the majority of us bumble along, referencing different resources, and reading package descriptions when we require a new function. I employ LaTeX on a very basic level creating templates for business correspondence and other paperwork. I'm also a registered trainer/assessor, but if I were to structure a LaTeX course based on my knowledge of LaTeX it would be too limited for many, and contain too much extraneous material for the rest.

  • not directed toward educational goals, but a comment on history, the basic latex document classes may be suitable foir computer science publications, but they are not suitable for math. ams-tex was developed for that purpose, and only later adapted for use with latex as amsmath; additional changes were required to make the latex document paradigm suitable for use by at least one math publisher with (at the time) more than 100 years of a publication track record. – barbara beeton Aug 20 '17 at 1:28
  • Basic math requirement is answered to with LaTeX. What I related was relevant to TeX, but that is accessible by way of \usepackage{amsmath} and \usepackage{mathtools} in the LaTeX environment now. – David Crosswell Aug 21 '17 at 7:29
  • not referring to the math. the top matter. that which goes into a later bibliographic reference to the current document, is insufficiently defined in the basic latex document classes. that is why every publisher has their input rules. if the top matter had been more carefully subdivided in the beginning, at least the ams would not have felt the necessity to make drastic changes, but would have modified only the appearance of the output, leaving the input conventions intact. – barbara beeton Aug 21 '17 at 14:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.