13 ms·
The Art of LaTeX: Common mistakes and advice for typesetting proofs
- carterschonwald 4y agoGreat cheat sheet, not enough folks know about \mid and friends. Once you’re in nyc let’s grab coffee sometime!
- fanpu 4y agoThank you! :) and sure!
- walnutclosefarm 4y agoI have a question: if what you have to write in order to create your beautiful and aesthetically pleasing proof, and thereby "establish your ethos and character" (presumably as a righteous and good), is an ugly and fragile instance of a poorly designed, inherently unreadable, archaic language that embodies none of the characteristics you are after, can the result really be "a work of art that combines both the precision and creativity of your logical thinking, as well as the elegance of a beautifully typeset writing?"
- contravariant 4y agoWell no, but LaTeX should be backwards compatible with TeX so there's always that option.
- fanpu 4y agoGreat question! Is there a specific domain/example that you have in mind? I don't think people intentionally use archaic language if their goal is to educate and enlighten, but in papers it is quite common for unnecessary jargon to be peppered in, which while probably obvious to the author, makes it hard for people new to the field to break in.
- fanpu 4y agoRealized I misunderstood your question. IMO the main design problem with LaTeX from a usage-standpoint is that there are too many ways of achieving the same thing, and oftentimes none of them is a clear winner. It's still the best option for a usable, programmable typesetting language that we have (i.e writing for-loops to draw structured graphs in TikZ...)
- titzer 4y agoMy personal beef with LaTeX, other than the utterly atrocious syntax, is that it a.) endlessly barfs on your terminal during its normal operation and b.) does not respond to normal terminal interaction upon an error (wth is it expecting? I interactively edit and correct mistakes!?). So it's scroll blindness and flailing all the way, a kludgy, rickety mess. Not to mention its utter mess of a package management system.
- w4rh4wk5 4y agoFor the terminal output issue, consider latexrun https://github.com/aclements/latexrun https://github.com/aclements/latexrun
- tephra 4y agoIt should be noted that TeX wa s of course designed to actually be interactive and stop letting you fix errors. I went through the texbook by Knuth last year and my eyes were opened (also note that I am an incurable (La)TeX fan so my opinion is biased)
- atlintots 4y agoIn this case, of course. The final product (the document), once produced, is much more independent of the underlying code than "normal" software. Once the document has been produced, it doesn't really matter whether you used Word or LaTeX or ConTeXt or whatever.
- w4rh4wk5 4y agoUntil you have to change, quote, or re-use parts of it, in another document.
- fanpu 4y agoThere are tools (i.e https://mathpix.com/ https://mathpix.com/) that actually does a pretty great job at LaTeX OCR, although you'll need to re-create labels and the like. I was pleasantly surprised that it replicated alignments & chose the right font faces while using it.
- ivansavz 4y ago> RE: ugly and fragile instance of a poorly designed, inherently unreadable, archaic language That's a lot of hate for LaTeX, and some of it is warranted, but you have to think of the results, not the source... It's not the source code that people are in love with, but the result (rendered PDF or via MathJax/KaTeX on the web). The "ugly" markup syntax allows you to produce beautiful, versatile, well designed, readable, and modern math equations. As for the latex source code, I think it's redeeming qualities are the fact that it is a standard (with over 40+ years track record). It's definitely not readable, or user-friendly (try adding or forgetting a single }), but people seem to get used to it after a while. Another thing I could say in defence of tex syntax, is that it is necessary complexity. If it wasn't the backslash-macros and curly braces, we would need some other way to express structure in equations, so the same complexity would be present in a new look.
- zzless 4y agoWhat a great summary! Unfortunately, many discussions of TeX vs alternatives are somewhat thin on details and are instead trading on emotions. As you mentioned in your comment, the choices made by Knuth are far from random. He even made it possible for anyone to change them! Not many people using TeX know that the choice of the backslash as an 'escape' character may be easily changed. Even the necessity of curly braces may be avoided using carefully designed macros. LaTeX took a different path but it is only one possible choice. It is telling that no real alternatives have emerged during the 40+ years of TeX's existence.
- ogogmad 4y agoAsciidoc, TexMacs, LyX, reStructuredText, Markdown (admittedly, only ish). None of them have become the standard. But some of the ones above - though excluding Markdown - are a complete replacement. Actually, even Markdown stands a chance if supplemented with enough HTML and CSS. HTML and CSS have practically replaced most non-maths uses of Latex.
- cratermoon 4y agoHow many of those rely on LaTeX syntax extensions to render equations?
- rsfern 4y agoGenerally agreed, writing should be a tool that supports clear thinking, and a giant mess of unreadable markup is not amenable for thinking. I’m still reading through this post, but it seems to have some great advice for making that situation at least a little better, like the trick with mathtools to make paired braces more readable I collaborate with some academics that strongly prefer to do all writing and editing in MS Word, but I’ve personally found that to be a lot worse for supporting clear thinking, especially if any math is involved
- DocTomoe 4y agoI am still looking for a text markup system that gives me good PDFs with DTP-grade text setting and and is plain-text, so I can work with standard version control programs. Right now, only TeX/LaTeX comes close. AsciiDoctor is not doing citations well, Markdown is basically a mess which differs in implementation, also footnotes and citations. Do you have something better?
- chaoxu 4y agoHow is Quarto? It uses Pandoc Markdown.
- elashri 4y agoThere was a discussion about that last year [1] [1] https://news.ycombinator.com/item?id=30042831 https://news.ycombinator.com/item?id=30042831
- hanche 4y agoI think (though I can’t find a reference) that Knuth hoped that some of the algorithms developed for TeX, such as the hyphenation and line breaking algorithms, would catch on and be used by other, non-TeX typesetting software. If that has ever happened, I a unaware of any examples. That’s a pity.
- gglitch 4y agoI don’t have an opinion about whether they’re better or worse, but have you tried groff or heirloom troff?
- carapace 4y agoYou're crapping on a thing that Knuth and friends made and gave you for free. Are you about to go write something better?
- walnutclosefarm 4y agoI don't think the fact that Knuth wrote it and gave it away has anything to do with the question I was asking. If anything, the fact that it's free may contribute to its ubiquity and longevity, notwithstanding its poor design and other undesirable characteristics. But none of that was the point of my question. The article on which the original post was made was effusive about how elegant and beautiful LaTeX output is, and how virtuous an author is for creating such works of art. It almost made it an obligation of anyone who writes math to love the look of LaTex. I'm asking, notwithstanding the output, if the input and process are a mess, is this really such a virtuous thing? I personally think not. Obviously, some others disagree.
- semi-extrinsic 4y agoLaTeX is robust enough and has a consistent enough interface that with some macros and snippets you can take real-time notes of people giving graduate level math lectures on a blackboard. If LaTeX is ugly, it's in the same sense as APL is "ugly".
- Shorel 4y agoAs ugly as it may appear to you, it is so much more readable than MathML Core. TeX is, in fact, still better than all the alternatives to represent mathematical equations in plain text created so far.
- charlieyu1 4y agoMathML is not a writing format, it is an output format that is designed to be machine readable. And I think most people complain about the non-equation parts of LaTeX.
- patrick451 4y agoI guess readability is in the eye of the beholder, but I find latex much more readable than html and usually more readable than reStructuredText. Markdown might be more readable, but it's so limited it shouldn't even be in conversation.
- KMnO4 4y agoI find writing LaTex is like painting a beautiful sunset using pig’s blood. The results are beautiful, but don’t look behind the canvas or too deeply into the artist’s mental health following that.
- generationP 4y agoTeX is not unreadable. It's hard to automatically parse, but it is easy to read by a human, unless the authors have been piling hacks and too-smart-by-half constructs. The latter case happens every once in a while but is generally pretty rare.
- amichail 4y agoTeXmacs allows you to typeset beautiful proofs via a WYSIWYG editor without the pain of TeX/LaTeX. Note that its name is doubly misleading since it is not based on TeX nor Emacs. It is however inspired by both. TeXmacs produces documents of similar quality to TeX/LaTeX.
- fanpu 4y agoI was initially dreading that it would be something inefficient like the equation symbol selector in Word, but after viewing the video demo on their website and seeing the speed of typing aided by heavy use of shortcuts, I'm intrigued. I'll try it out someday!
- zzless 4y agoTeXmacs is a great project, no doubt, but you have mentioned WYSIWYG as one of the advantages. This is the main reason I do not use TeXmacs to create documents (I do use it to create online lectures). You may like or dislike LaTeX/TeX (and the discussion is usually too emotionally charged for my taste) but the fact that it is a text format (not as verbose as, say, XML, at that) which is more or less standard is a deciding factor for many people, including myself. On a personal level, while I slightly dislike LaTeX style macros, I absolutely adore TeX's design (yes, including syntax). It is a matter of taste, of course. I am aware that TeXmacs can export LaTeX, it is not quite the same. LyX is another (better in my view) WYSIWYG option, if one is desired.
- ogogmad 4y agoA TexMacs file can be opened up in any text editor. It's readable -- XML-like without quite being XML. Presumably, this can be used to work around some limitations of the WYSIWYG editor. I think LyX's file format is not as well-designed.
- ogogmad 4y agoIs there an equivalent of \NewCommand in TexMacs? I can't find anything by Googling.
- 4y ago
- cratermoon 4y agoSeveral of the images are broken links. Perhaps an example of Muphry's Law?
- fanpu 4y agoRefreshing might help (my guess is it might be due to img fallback issue), thanks for flagging this and I'll be investigating!
- fanpu 4y agoShould be fixed now. First time hearing about Muphry's Law, definitely gave me a chuckle!
- cratermoon 4y agoWorks now. I do very little writing that requires math, although I did have occasion to present Muller’s Recurrence for a discussion on floating point arithmetic. The tip "Expressions Should Be Punctuated Like Sentences" is a good one, and generalizes somewhat to inline code or any inline figure or table in writing.
- hanche 4y ago> First time hearing about Muphry's Law It was probably a mipsrint.
- cratermoon 4y agoNope.
- hanche 4y agoI knew that, was just playing the joke back. I guess it misfired. Or maybe not.
- cratermoon 4y agoI missed it.
- Tainnor 4y agoSome of the images don't appear to render for me. Also, the author includes an example of \int xyzdx and makes a note of using appropriate spacing. It is my impression that commonly the differential operator is typeset differently, that is: \mathrm{d}x. Otherwise, great tips.
- ogogmad 4y agoIn physics, it's \mathrm dx. In mathematics, it's dx.
- Tainnor 4y agoIt would appear that it is even more complicated than that and so depends on nationality, the field in question etc.: https://tex.stackexchange.com/a/88961/31889 https://tex.stackexchange.com/a/88961/31889 TIL
- quietbritishjim 4y agoHistorically, by which I mean professional typeset documents in early 20th century, it was upright d in both. It's often italic dx in maths now probably just because doing it right is tricky (at least non-zero effort) in LaTeX. In many articles, there isn't even spacing around differentials. That doesn't mean that is correct too. It just means that, like upright d, the author has more pressing issues than small details of typesetting. It similar to how vectors (in physics / applied maths) are represented by upright bold letter. Historically, these were bold-italic - the same as how most variables are italic. But early versions of TeX only supported fonts in regular, italic and bold - no bold italic variants existed (even now, bold italics are not universally available for Greek characters). So people used upright bold for vectors, and now it's assumed that it was deliberate.
- zeur0aoV 4y agoNot really. It has nothing to do with LaTeX. Most of them are italic in mathematics . For example, in Hermite's textbook (1882) (https://gallica.bnf.fr/ark:/12148/bpt6k97981084/f31.item.texteImage https://gallica.bnf.fr/ark:/12148/bpt6k97981084/f31.item.tex...), page 13, the dω is italic. In Klein's Lectures on Mathematics (1894) (https://www.mathunion.org/fileadmin/ICM/Proceedings/ICM1893.2/ICM1893.2.ocr.pdf https://www.mathunion.org/fileadmin/ICM/Proceedings/ICM1893....) page 20, the dx is italic. In Goursat's textbook (1933) (https://gallica.bnf.fr/ark:/12148/bpt6k9454797/f107.item https://gallica.bnf.fr/ark:/12148/bpt6k9454797/f107.item), the dx is also italic.
- DiogenesKynikos 4y agoLaTeX is great, but God forbid you want to move a figure up a centimeter on the page. That'll cost you an hour of reading through StackExchange threads, and you'll probably come up empty.
- generationP 4y agoJust don't use figure when you don't want them to float, but just use \includegraphics or whatever environment you're using? Floating figures are a pain in the ass in any system, as their positioning relies on the rest of the text already being formatted but simultaneously mess with that same formatting.
- mattkrause 4y agoIt is not exactly a picnic in Word either though....
- generationP 4y agoMost of this is good advice, but I don't see the \mathbbm vs. \mathbb distinction as anything other than subjective taste. Also, I use things like \newcommand{\abs}[1]{\left| #1 \right|} in the preamble. This way, I can use \abs{...} without any asterisks, and it automatically adjusts its size. In the 1% situations where I don't want it to adjust the size, I write the delimiters manually. Making maths look good in LaTeX is pretty well-understood these days; authors who don't are usually just being lazy. The big undocumented mess with LaTeX is making bibliographies work correctly. The "standard" bibtex workflow is broken in many ways, and I have never seen a tutorial on how to fix it. With bibliographies being such a minuscule part of a mathematical paper, I'm not surprised that no one cares, but the result is lots of references that are imprecise, missing important info or plain wrong.
- enriquto 4y agoBoth mathbbm and mathbb are wrong for number sets. These fonts look like the blackboard hack that you use to simulate boldface using chalk. On a computer you don't have this problem and you can simply use mathbf (actual boldface).
- fanpu 4y agoInteresting explanation on how it developed historically. I've seen mathbf used in some books, but I guess old conventions are hard to change.
- generationP 4y agoIt might have originated as a hack, but now it's a font in its own right. Why not use it? It's quite common to see \mathbb{R} used for the actual set of reals, while \mathbf{R} means a totally ordered field (i.e., an abstract object behaving somewhat like \mathbb{R}). The distinction is deliberate and the notation is good.
- enriquto 4y ago> Why not use it? Better question: why use it, when you can use the real thing? Mathematicians concerned by typography universally use real boldface. For example: Terrence Tao's blog, Donald Knuth, Paul Halmos (author of "how to write mathematics"), and the famous journal "Publications Mathématiques de l'IHÉS" which is the undisputed gold standard in mathematical typography. They use real boldface for the number sets N, Z, Q, T, R, C. I've never seen a boldface R to mean a set different than the real numbers. Maybe this is some fringe custom in model theory, but in mainstream mathematics it has a clear and standard meaning. Can you point me to a paper where they use a boldface R with such a meaning (i.e., different than the reals). I'm sure that this usage would always be accompanied by a clarification to avoid any confusion.
- eterevsky 4y agoMaybe I'm nitpicking, but the very first section of this document, entitled "Typesetting as a Form of Art" contains in the first two lines an incorrect opening quotation mark (`` instead of “) and a hyphen (-) instead of an em-dash (–).
- fanpu 4y agoAh, I guess that's what happens when you do both Markdown and LaTeX in the same document! Thanks for pointing it out, I've also been pretty sloppy with hyphen and em-dash in normal writing. Maybe someone could write a similar post for online HTML content in the future?
- quijoteuniv 4y agoI understand that some people do not want to use Latex, but i do not get the hate. Not for you? Move on, do you own thing
- daly 4y agoLatex and Tex, my goto language for beautiful documents. Try rewriting Knuth's books with markdown.
- chaoxu 4y agoMany LaTeX tricks only get passed down from advisors to students, or from collaborators to collaborators. Rarely someone would look for how to improve their typesetting when all they want is to quickly communicate content. It be nice if content and typesetting can be completely separated, where I just write content, and something (LaTeX, AI, some manual typesetter) does all the typesetting. Also, should I be the one controlling how the reader consume my content? Maybe the reader prefers another font? Or the reader is viewing in a kindle so pdf page size should be different? This would be impossible unless the reader have my LaTeX source code and compile it themselves. But it is super simple for epub, or html webpage (by modifying the css).
- pinewurst 4y agoTo a certain degree, the LaTeX environment is already like that. I designed my custom resume style years ago and rarely touch it. I often tweak the actual content which gets poured into the style to produce the final document. The few changes I’ve made to the style have never affected the (separate) content either.
- zzless 4y ago> This would be impossible unless the reader have my LaTeX source code and compile it themselves. But it is super simple for epub, or html webpage (by modifying the css). Well ..., wouldn't the html page be the source code in this case? Also, in most cases changing the look of a LaTeX document is as simple as changing the docuent class or switching to a different package. Also, modifying CSS is anything but simple in some cases, especially when the original style is not ideal.
- fanpu 4y ago> Many LaTeX tricks only get passed down from advisors to students, or from collaborators to collaborators. Which is a great point on why the average quality of LaTeX homework submissions by undergraduates without any research experience usually makes for a less-than-ideal grading experience. And this is not about the nit-picky mistakes, but the visually glaring ones.
- WolfOliver 4y ago
- yodsanklai 4y agoOne thing I don't miss about my research years is latex. It does produce beautiful documents and kudos to Knuth/Lamport for producing a system that stood the test of time. But what a pain to use.
- ipunchghosts 4y agoIt only lives on through cut and paste previous latex files and stack overflow lol
- gdprrrr 4y agoUsw autoref instead of ref and it will add the "Figure ", " Chapter " etc automatically. And for Differentials, dwfine a semantic macro like \dd from the physics package. I find quotes are besr left to csquotes, which lets you define the type of quotes and show they nest in the preamble.
- fanpu 4y agoWish I knew about autoref earlier, it also increases the area spanned by the hyperlink generated to the entirety of "Figure 1" instead of just "1" in the case of ref.
- asymmetric 4y agoDoes anyone know of similar lists of best practices, but for humanities? E.g. for writing papers, study notes, presentation slides, etc. I use org-mode to produce Latex, and find myself always needing to remove the TOC, for example. The borders are always too wide, etc. This is one that has some nice tips, wondering if there are others: https://www.colinmclear.net/posts/teaching-notes/ https://www.colinmclear.net/posts/teaching-notes/
- John23832 4y agoI really wish there was a way to have shared editing on a doc, similar to google docs, that used LaTex. I often have to share docs for work (in google docs) and the lack of a clear way to format as eloquently as LaTex makes me not even try.
- orthonormel 4y agoSomething like overleaf.com ?
- everydayentropy 4y agoHave you tried overleaf?
- fanpu 4y agoOverleaf (https://overleaf.com/ https://overleaf.com/) is pretty popular for this, and also tracks things like edit history
- xigoi 4y agoUnfortunately, it doesn't allow you to bring your own editor, so I have to put up with its half-assed implementation of Vim.
- grumdan 4y agoIt doesn't work super well during live collaboration, but Overleaf does allow git access to the underlying document: https://www.overleaf.com/learn/how-to/Using_Git_and_GitHub https://www.overleaf.com/learn/how-to/Using_Git_and_GitHub
- jakobov 4y agoAnyone know of any good typesetters who I can hire to typeset an ebook?
- grecy 4y agoI've written my books in Latex - the pdf output goes to Amazon for the print copy, and then I run it through pandoc to get a perfectly formatted epub that I upload to amazon and apple and anywhere else. It takes a bit to get setup, but now I have the template going it makes a perfectly formatted book a breeze. I wrote about it here: http://theroadchoseme.com/how-i-self-published-a-professional-paperback-and-ebook-using-latex-and-pandoc http://theroadchoseme.com/how-i-self-published-a-professiona...
- billfruit 4y agoIs there a reasonable assessment of where LaTeX's capabilities are falling short? One of these may be laying out tables without need for manual intervention/adjustment. Another could be easier ways to customise look and feel of documents.For example the "letter" document class is too bare-bones.
- generationP 4y agoThere are lots of things that are worth improving. The lack of accessibility features (structured PDF, alt-text), or more precisely the glacial pace at which they are getting developed, is grating. In truth, a well-written TeX file is itself accessible in most reasonable senses, but not everyone posts TeX sources of their work. It reminds me of the early 2000s when making PDFs was considered high wizardry and everyone was dealing with half-broken PS and DVI. Better tables would be nice, but it's not clear what a perfect support for tables would even be. Unlike HTML, TeX has deal with page size limitations, and it's far from clear how tables should adapt to those.
- dfan 4y agoIf this article gets even one author to stop using < and > when they mean \langle and \rangle, it will be worth it.
- hello2023 4y agoIn the spacing section, the author's suggestion to use absolute spacing operator (e.g \;) is actually not recommended. a better way is to make `dx` a math operator (`d` is an operator isn't it?). Some other suggestion is not actually recommended in the official documentation of amsmath as I recall. Hope this helps.
- hanche 4y agoI use \mathop{}\!{\mathrm d}} myself. That is a bit convoluted, but it takes care of the spacing in just about every context.. Of course, I put that in a macro definition so I don’t have to sprinkle it all over my document.
- gnull 4y agoOne bit I would add: don't use xspace package. If you defined a macro with 0 argumemts like \newcommand\kek[0]{kak} You must always put {} after it's invocation like "\kek{}". If you do "\kek", that may eat the following space in some cases. Doing "\kek\ " or "\kek\xspace" is bad and harmful.
- sampo 4y ago> Macros can also take arguments to be substituted within the definition. Some journals ask you to submit your manuscript in plain LaTeX, without defining your own macros.
- dachryn 4y agosince a macro is just a macro, isn't it fairly easy to just inline the macro's then?
- litographic 4y agoSlightly off-topic question: any suggestions for modern presentation LaTeX themes (besides Metropolis, https://github.com/matze/mtheme https://github.com/matze/mtheme)?
- garrison 4y agoThe final point, involving labels and references, could be improved by mentioning cleveref: https://ctan.org/pkg/cleveref?lang=en https://ctan.org/pkg/cleveref?lang=en
- OJFord 4y agoNot a single mention of 'hbox' (I opened and immediately grepped) - surely the primary issue (or seemingly non-issue but annoying error/warning) anyone runs into is 'overfull hbox', typically without any idea what an hbox even is anyway.
- philistine 4y agoYeah! When I make my book into PDFs, I get a ton of those yet see no issues visually.
- xigoi 4y agoIf you look carefully, you should be able to see that the mentioned line slightly overreaches the edge of the page.
- svat 4y agoThe linked post is not a comprehensive manual of LaTeX but just a collection of typesetting tips that the author found interesting. TeX is at heart a system for setting, breaking and laying out boxes. Each character (e.g. 'T' from font Helvetica, say) is a box, a paragraph is a sequence of these boxes (with "glue" for the words), which is broken into lines (each line is a hbox), which are assembled into paragraphs and pages (vboxes). It is a remarkable evolution in patterns of computer usage (since the 1970s/early 1980s when TeX was written) that people today expect to use programs without even skimming the manual (e.g. this is covered on page 27–28 of The TeXbook). Using TeX without caring about boxes and glue is missing the point, I think. (Surely there are alternative simpler programs if one doesn't want to be bothered about the finer points of typesetting.) Anyway, see e.g. • https://texfaq.org/FAQ-overfull https://texfaq.org/FAQ-overfull • https://tex.stackexchange.com/questions/35/what-does-overfull-hbox-mean-why-is-there-a-black-mark-at-the-end-of-a-line https://tex.stackexchange.com/questions/35/what-does-overful... • https://tex.stackexchange.com/questions/138/what-are-underfull-hboxes-and-vboxes-and-how-can-i-get-rid-of-them https://tex.stackexchange.com/questions/138/what-are-underfu...
- OJFord 4y ago
- SeanLuke 4y ago#1 on my list has got to be the myriad of LaTeX-writers who think that math variables can be longer than a single letter. That is, they write things like: $foo + bar$ ... not realizing that LaTeX is typesetting these to imply f times o times o + b times a times r. It looks horrible. A simple fix would be: $\text{\it foo} + \text{\it bar}$