87

What are TeX's limitations in typography, book design and publishing? (and here TeX also includes all its derivatives, like pdfTeX, LuaTeX, and macro packages built upon it, LaTeX, ConTeXt etc.).

Some things (like math and references) are extremely easy in TeX. There are some things that are harder to do in TeX-based systems, but they are possible, even if cumbersome (like precise control of images' placement or manual control over layout and design). Solutions to some problems have been found (like microtype). Some things are rarely talked about (like color profiles).

Please mention what is either extremely hard to achieve with TeX or is not possible at all (due to inherent limitations of TeX, or due to bugs/limitations in the available tool chain). Please mention also which technological steps do not fit well with TeX workflow.

sastanin
  • 221
  • 11
    I think this is an acceptable question for this site, as a community wiki, where people should answer one tex limitation per answer. – Lev Bishop Sep 04 '11 at 14:56
  • 4
    Color profiles are not well supported in latex, although you can always use raw pdftex primitives if you know what you want. I believe Context has good support for them though. – Lev Bishop Sep 04 '11 at 14:58
  • @Lev Bishop I didn't find community wiki checkbox. It seems it is not available anymore for questions — http://blog.stackoverflow.com/2011/08/the-future-of-community-wiki/ — or at least not for low-rep users. – sastanin Sep 04 '11 at 15:06
  • @Lev Bishop BTW, thanks for pointing out that ConTeXt supports color profiles. – sastanin Sep 04 '11 at 15:11
  • @jetxee: Only moderators can turn a question to community wiki. – Tsuyoshi Ito Sep 04 '11 at 16:45
  • As desired, I changed it to community wiki. – Stefan Kottwitz Sep 04 '11 at 17:15
  • 2
    I think the question should be closed or reworded. There are things that TeX can't do at the moment, but things change and the answers will possibly invalid in the future and therefore misleading. - If we answer the question, we should define first what TeX is. – topskip Sep 04 '11 at 17:35
  • 12
    Well TeX can't prevent the coming Apocalypse, for example... – Yuji Sep 04 '11 at 17:51
  • 4
    I was tempted to post something along the lines of @Yuji ... TeX can't bake cakes :) As for the rewording: I guess it makes sense to specify the current state of TeX in some way, and also to ask about limitations or borders, to indicate the relatedness of the impossible tasks, which is implicit so far. – doncherry Sep 04 '11 at 22:06
  • @Patrick Evidently, I ask about what are the current limitations of TeX as a technology and of its modern tool chain. I define TeX as all its derivatives and all macro packages built upon it. – sastanin Sep 05 '11 at 10:03
  • TeX is a Turing complete language. So it can make almost everything (except for some limitations by Gödel's incompleteness theorems, Halting problem and other). – m0nhawk Mar 07 '13 at 16:34
  • floats surrounded by text is not natural to make in TeX, see http://tex.stackexchange.com/questions/147577/having-right-and-left-wrapping-floats-nicely-respecting-page-boundaries-and-marg/147986#147986 – user2987828 Dec 02 '13 at 09:16
  • @Yuji Sometimes I believe the apocalypse is coming for us in the form of bad typography. In that case, who knows. But since it's actually more likely to be some form of environmental destruction that's going to get us into trouble, I believe you are right and TeX can't do much to help. – Christian Apr 28 '14 at 21:18

13 Answers13

57

TeX has no real way to do river, lake and hole elimination. This would require a much more expensive paragraph layout algorithm than the Knuth and Plass dynamic programming.

Lev Bishop
  • 45,462
  • 2
    I think it is possible but impossible within manageable time. It is possible to implement such an algorithm in Lua or even TeX. But I only heard of such an algorithm at the order O(n^3), cannot remember where I read about it – Yan Zhou Sep 04 '11 at 15:06
  • 10
  • 3
    Are there other programs that are known to avoid them automatically? – raphink Sep 05 '11 at 16:28
  • 8
    @Raphink http://ant.berlios.de/ (Ant) states that it does so, but even with the help from the author I was unable to see any river elimination. (I did a bit of research on that area). And there are rumors that InDesign does that, but there is no official note from Adobe about that, so river elimination is probably due to the total fit algorithm in ID. – topskip Sep 07 '11 at 06:00
  • 2
    @ℝaphink Yes: Patoline – yo' Mar 08 '13 at 21:49
  • 1
    @tohecz I couldn't find any mention of this in the patoline book. Where did you see it? Do you know what algorithm they use to remove rivers? – Lev Bishop Mar 11 '13 at 09:16
  • @LevBishop I only know that it is possible. The principle behind is that the glue is not evenly distributed to all the spaces, so you shift the words a bit to avoid rivers. I don't know details though, and the lack of good documentation to this system is one of the things that make me catious about it. I know it only because its author is one of my workmates. – yo' Mar 11 '13 at 12:20
32

The definitive answer to this is perhaps Donald Knuth's own answers, given in an earthshaking announcement in 2010 and recorded in this video and transcribed in the TUG journal, TUGboat, Volume 31 (2010), No. 2, pp121ff.

Dayakar
  • 39
mas
  • 5,949
27

Some things that are perhaps possible in TeX (with some programming) but not built in LaTeX or plain TeX itself:

  • Automatic paragraph flow around arbitrary shapes (like images)
  • Autokerning based on the shape of the glyphs
  • good multi column support (balancing, images/formulae crossing multiple columns)
  • text areas with overflow capabilities ("read more on page 3")
  • Output to an "open" format such as InDesign (for editing afterwards) or XML
  • Some way of splitting a vbox at a point (should break an image in two parts for example)
  • XML input
  • This list could be continued, but you get the point: magazine layout is not easy in TeX
topskip
  • 37,020
  • 2
    you should divide this list into separate answers, since as you say, some of these have solutions, whereas others have only partial solutions/workarounds or could only be solved in principle with tricky tex programming that nobody has done yet. If you put it into separate answers, people can more easily edit in additional information. – Lev Bishop Sep 08 '11 at 15:21
20

TeX does not perform a global optimization of its cost functions but does so on a page by page basis. While I think it might be possible to solve this without touching the kernel, this must be pretty hard to do efficiently and transparently and I am not aware of any package that has tried to do this.

For an example of the practical effects of this deficiency, see How to spread floats automatically over a whole chapter?

I stole this picture from there: non-optimal distribution of text and floats on multiple pages

Christian
  • 19,238
15

One of the things that are impossible in TeX90 is typesetting the first line of a paragraph in a different font than the rest of the para - with the possibility of hyphenation between the first and second line.

EDIT: It seems the magaz package implements this.

14

TeX was not really designed for fully automatic typesetting, as you may want when the source document is computer-generated (for things like database reports or equipment manuals), or needs to be typeset in many different page geometries. These things are possible, but they need some care. The main problem is that TeX wants to set beautiful paragraphs and if it can't do that, then it throws an overfull hbox and expects the author to deal with it (eg, by rewording the offending text, or marking additional hyphenation locations). Some discussion of lowering TeX's standards is in this FAQ answer, which will eliminate overfull boxes, but it's still true that TeX is at it's best at when beautiful paragraphs are possible.

Here's an example:

\documentclass{article}
\usepackage[text={3.01cm,8in}]{geometry}
\begin{document}
{%Help TeX not to give up too easily....
\tolerance=9999
\setlength{\emergencystretch}{1em}
TeX was not really designed for fully automatic typesetting, as you may want
when the source document is computer-generated (for things like database reports
or equipment manuals), or needs to be typeset in many different page geometries.\par}

%I'd rather see something like this TeX was not\break really designed for\break fully automatic typesetting, as you may want when the\break source document is computer-generated (for things like\break database reports or equipment manuals), or needs to be typeset in many different page geometries. \end{document}

Result: enter image description here

Automatic breaking of displayed equations is another difficult aspect of automatic typesetting, although the breqn package makes an attempt at this.

user202729
  • 7,143
Lev Bishop
  • 45,462
  • 4
    sorry, but this is simply false. You can tweak linke breaking, so that no overfull boxes will be generated. You can do even multi pass line breaking with different parameters, so that you really get the best paragraph shape. In our database publishing software (http://speedata.github.com/publisher/) that we use for creating high quality product catalogs (100% automatic) we get awesome typography due to the full control we have over TeX. – topskip Sep 07 '11 at 06:04
  • @Patrick: That sounds really interesting! I haven't been able to find any examples of the documents produced with Speedata Publisher on your website. Is there a showcase somewhere? – Jake Sep 07 '11 at 06:17
  • 1
    @Jake Not yet. We are still in the process of opening our software. There is even no english translation of the manual yet. We will have a more or less finished package by spring 2012. – topskip Sep 07 '11 at 06:24
  • 1
    @patrick: if the situation is easy: short words, wide textblock, long paragraphs, then beautiful (or at least decent) paragraphs are possible, and TeX will certainly find them. If the situation is difficult: long non-hyphenatable words, narrow columns, short paragraphs, then many paragraphs will need to be ugly. Yes you can tweak the parameters so that TeX doesn't produce overfull boxes in such cases (as I wrote), but still TeX's formula for "badness" (sum of cubes of the stretches/shrinks) isn't optimal for choosing which ugly paragraph is least bad. I edited my answer to clarify. – Lev Bishop Sep 07 '11 at 06:25
  • 3
    @Lev but then the typesetting task is simply impossible or extremely hard and this is not TeX's fault. Show me a formatter that is better then TeX (with a specific paragraph). IMO TeX is by far the best software out there for unattended typesetting and for database publishing (in terms of speed, quality, robustness, features and so on), and this is why we chose TeX (specifically LuaTeX) for that task. – topskip Sep 07 '11 at 06:32
  • 1
    @patrick: I never claimed there was anything better than TeX for this task, just that this is one of the things that TeX can't do :-) I added an example – Lev Bishop Sep 07 '11 at 07:27
  • @Lev - your example is even worse. I see 7 underfull/overfull boxes with your manual broken paragraph! – topskip Sep 07 '11 at 07:43
  • @patrick, sure it reports underfull and overfull boxes, but look at the result (I edited it in). In my opinion the manual version looks better, do you disagree? – Lev Bishop Sep 07 '11 at 07:44
  • @Lev somehow I forgot to submit my last comment or SE ate it. You can do multipass linebreaking depending on the overall or the local badness of a paragraph (very easy with LuaTeX). There are many parameters to tweak, such as fontdimen 2,3 and 4 or to use font expansion. Don't forget to use proper hyphenation patterns (in your example: computer-generated can't be hyphenated because of the "-" - in our typesetting tool we change this to a breakable hyphen) And one hint for good looking paragraphs: don't use large values of tolerance for this will guarantee you bad paragraphs. – topskip Sep 07 '11 at 08:40
12

Adding to the collection:

Q: How to undo \usepackage?

A: You can't.

To shamelessly copy and paste from the answer so that SX won't auto-comment my answer anymore:

Tex/Latex have what is called monolithic state: you can't cleanly isolate the configuration done by one package from another, which is one of the reasons why incompatibilities are possible. This means there is no way to identify how to undo what changes the \usepackage command has caused.

Christian
  • 19,238
  • 1
    To be fair you can't really "undo" e.g. a Python package import either, if that package import does nontrivial things e.g. monkey-patch some functions in other modules. Fortunately most Python packages are "well-behaved", but it's just not the case in TeX – user202729 Apr 12 '22 at 16:34
8

TeX, and Lua in LuaTeX are both Turing complete languages. So they should be able to do pretty much anything.

However, some things are more difficult due to the limited set of features of the language. Some other things require new algorithms, which may not perform reasonable well (say requiring $O(n^2)$ or even more computing times).

One particular example I can think of is grid typesetting. This is one thing I always wanted to do but haven't found any elegant solutions in the TeX world yet.

Yan Zhou
  • 9,032
  • 19
    No, TeX being Turing complete does not mean that in principle it can do "pretty much anything". One major point is that TeX doesn't know how the glyphs it uses look like - it only knows the bounding boxes. (This question of mine gives an idea what I mean.) – Hendrik Vogt Sep 04 '11 at 16:29
  • 5
    Grid computing is no problem with ConTeXt and there is also a solution with KOMA-Script, but I didn't find it –  Sep 04 '11 at 16:29
  • 2
    @Herbert: That's the gridset alpha package -- but it provides only a partial solution (a \vskipnextgrid macro). – lockstep Sep 04 '11 at 20:38
  • 2
    In my experiments, I've found out that grid isn't a problem until you have inline maths. – morbusg Sep 07 '11 at 06:25
  • @morbusg Exactly! – Yan Zhou Sep 07 '11 at 07:39
  • 7
    I wonder why you do your typesetting in TeX then at all. Just use a Turing machine – it can do everything TeX can. – Christian Jun 22 '13 at 14:57
3

Automatic splitting of floats for a better overall look (https://tex.stackexchange.com/a/4682/13450).

This is of course related to the general problem of a lack of global optimization but more specific. It would be nice to have floating text environments (tables, listings, text boxes, subfigure collections ...) that were split into two smaller parts if this were to improve the overall layout of the document (footnotes already do something like this).

Christian
  • 19,238
2

TeX and LaTeX is not really good at constructing dictionary-style texts.

It's really designed to expect tables and text as separate entities, and is not really good at flowing text from one minipage to another (like in magazines - continued on page ...).

One document i am writing at the moment, has a formatted set of formulae definitions, followed by a few paragraphs of text, and then a few more formulae, and then more text. I am currently doing this with the {tabbing} environment, with the \kill line set in the preface sections. It works, i suppose.

I'm still trying to get hanging numbers to work. Some places, such as running text, it is appropriate to use hanging numbers, rather than block numbers, but i can't see how to do this. I downloaded a package printnum where the documentation is in hanging numbers in the required style, but it's set to decimal, rather than twelfty.

1

Somewhat similar to Lev Bishop's answer: outputting the same file to different formats.

If I want to publish an article to arXiv, my HTML blog, a ePub book, and Git-whatever to accompany the code, I'll have a really long day with Pandoc and other tools instead of just iterating over targets such as PDF, HTML, ePub, Markdown.

As far as I understand, Tectonic aims to partially solve this problem.

0

Some miscellaneous points. They're mostly developer-oriented rather than user-oriented.

user202729
  • 7,143
  • Side note, assuming TeX's csname-lookup hash table is truly O(1), everything can be done in other language can be done in TeX unexpandably in the same time complexity. Only expansion-only processing has the restriction. – user202729 Apr 12 '22 at 16:58
0

As far as I remember, TeX is rather weak in prepress: imposition, bleed, trim, Flattermarke, paper thickness accommodation when folding (whatever it's called), etc.

So, basically, you cannot just take TeX output to printer and print your book directly from it.

  • 2
    At least one math publisher, which happens to have an in-house professional printing department, has managed to manage this successfully. But, admittedly, math books and journals aren't as wildly designed as popular tabloids. – barbara beeton Apr 12 '22 at 19:17