Hacker News new | past | comments | ask | show | jobs | submit login
The Art of LaTeX: Common mistakes and advice for typesetting proofs (fanpu.io)
277 points by fanpu on Jan 8, 2023 | hide | past | favorite | 146 comments



Most 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.


This is the first time I have seen such a complaint against bibtex. Yes bib files are finicky to write correctly, and bibtex can be a pain to use. But bibliographies are never "imprecise, missing important info or plain wrong." I've written 100s of pieces with latex+bibtex, papers, websites, reports, books. bibtex always makes citations and bib entries look like what I or the publisher need. If something is missing, then one is using the wrong style.


I have seen very few fully correct bibliographies written with bibtex in the wild. Not everything wrong with bibtex is a bug; the big problem is that bibtex is not adapted to its modern usage. A non-comprehensive list of problems:

1. Does anyone run bibtex directly from the command line? No, it's an extra step and the syntax is hard to memorize (should it run on the tex or the bib, and with or without the extension?). Instead, everyone eventually uses some form of script that does "pdflatex; bibtex; pdflatex; pdflatex" or something like this. Nice and slick; unfortunately it means that all warnings get hidden from view. A common mistake (particularly when copypasting) is accidentally having two AUTHOR fields in a bibitem, which causes the second to be ignored. No way you'll notice until you look carefully at the bibliography or read the bibtex log. It doesn't help that many of the warnings are false alarms.

2. Writing bibitems is probably as painless as it could be, but still painful enough that most people have "wandering" bib files that move from project to project. Unfortunately, this creates lots of problems:

2A. A book gets a reedition, or an arXiv preprint gets updated. You just update the reference, right? Wrong, of course, because your old references now lead to the wrong pages, sections, theorems.

2B. There are bibliography styles that print DOI fields but not URLs. There are ones that print URLs but not DOIs. There are some that print both, which is redundant. With a wandering bib file, which ones do you cater to? No way to do right by them all.

2C. With grey literature, a URL is often necessary, but many bibliography styles don't print URLs. So you end up including it in a NOTE field, which of course gets it duplicated in those styles that do print URLs.

3. Too many foot-guns.

3A. Bibtex (or most styles) automatically removes capitalization in titles ("Generalizations of dyck words"). Why? Why??? Yes, you can fix it by putting the {C}apital letters in braces. But why should you?

3B. You cannot use the packages or macros from your tex file in your bib file, as it's a separate file. Of course... but that makes you wonder why it should be a separate file to begin with.

3C. Yes, you heard it right: no package, in particular no unicode support.

3D. Basically every bibtex tutorial tells you to not trust bibitem-generating services, even the most official ones (IEEE, ACM). But no one has the time to do this on their own, and it stands to reason that there should be a common source at least for everything that is published and indexed. We got ORCID and DOI; is this that much harder?


By these standards, are any citation managers adapted to modern use?

I’m definitely open to the idea that we should change how we refer to other findings, but EndNote, Zotero, and the like also can’t save you from new editions, overly-strict rules about reference formatting, and bad publisher-provided information.

If you can deviate slightly from a particular reference format, it’s fairly easy to emit either a DOI or a URL (but not both): https://tex.stackexchange.com/questions/154864/biblatex-use-... One of the linked answers even suppresses DOI-like URLs.


The alternative is to just write the bibliography by hand. This means possibly having to make changes before final publication to adapt to the journal's style. But it is faster in my experience than getting things into bibtex pre-emptively, particularly as the latter doesn't reliably prevent problems at publication time. And it is sufficiently transparent that you don't have to deal with sneaky silent errors.


I have never found a silent error. If bibtex is not happy, it complains loudly. I use the style files given by the publishers and it always comes out OK. Never had a publisher complain about the bibliography when using their styles, and they do check, and complain about a lot of things.

You must have really bad luck with bibtex.


I agree with much of what you say. I certainly find bibtex frustrating. On your specific points

1. I might be the only one, but I do sometimes, for the reasons you say. To debug it. But yes, debugging bibtex files is a a real pain.

2. yes, but that is hardly bibtex's fault, would be the same with any system.

2A. (same response as 2)

2B Yes, and so have both fields in the bibtex files. Its the publisher who decided what they want, DOI, ULR or both or neither. Not bibtex's fault

2C dont know what "gray literature" is, sorry.

3. YES!

3A, Think you always will need something like that regardless of bibliography system. The publisher dictates only first word in title is capitalised, how then do you tell it to capitalize USA or Mary? {} is as good as any alternative.

3B. yes. I never had any need for that. do you mean \usepackage[utf8]{inputenc}

3C. yes, to be safe, one needs these weird latex formatting for foreign characters.

3D. Yes. Well I have the time. When I get a bibtex entry from some external source, It usually needs tweaking. And usually fastest is just to write it manually. But its a a trivial amount of effort


For 1, I just use latexmk. I honestly assumed that was standard but I guess not? It comes with TeXLive anyway. For the rest, I use Zotero with betterbibtex and with both that and LaTeX in general I use the more recent biblatex instead of bibtex.

This won't fix everything you've mentioned, but I feel like I generally have a lot fewer issues than what your comment would suggest.


If they make it into the wild, who cares if they are fully correct? The rules for a “fully correct” bibliography are too strict anyway. DOI or URL? Who cares? The reader is just going to search for the title anyway. As long as it doesn’t bounce off the publisher it is fine (which, it must not be bouncing off the publishers if it makes it into the wild).


Googling the title works for reasonably new papers. Not so good for textbooks, old papers (titles used to be a lot less expressive 50 years ago), conference proceedings (often not indexed by article anywhere, and the name of the volume can be ambiguous), grey literature like lecture notes (a URL would allow you to use the Wayback Machine).

Also, don't count on authors to get the title right.


Both 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).


It 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.


> 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.


True boldface has a much darker type color than blackboard bold, thus drawing your eyes to it. But usually, the occurrences of, say, the real numbers are not the most interesting or important part on the page and they thus don’t deserve that emphasis.

(Also, admittedly, I like the look of these letters.)


In his papers Terence Tao is inconsistent [1][2][3], maybe because of formatting requirements? But boy is real boldface ugly [3] and sticks out like some tomato ketchup on a white wedding dress.

[1] https://arxiv.org/pdf/1611.07441.pdf

[2] https://annals.math.princeton.edu/wp-content/uploads/annals-...

[3] https://arxiv.org/pdf/math/0512114.pdf


Huh, it appears a lot less frequent than I thought. I had misremembered some \mathrm{R}'s as \mathbf{R}'s.

That said, I still feel that I've seen every \mathbf letter used for something other than a standard number set somewhere. But probably not in the mainstream.


Who is Terrence Tao? Do you mean Terence Tao?

(if we are nitpicking about typography...)


Heh.

Sorry about that. A common typo. The keys are like right next to each other.


That would be going against the near-universal custom of using actual mathbb. They don't look like a hack to mathematicians because they are used everywhere and most people like them. Mathbf is rare and I don't recommend it.


How about using the Unicode characters ℕ, ℤ, ℚ, ℝ, ℂ, etc.?


Interesting explanation on how it developed historically. I've seen mathbf used in some books, but I guess old conventions are hard to change.


Use `DeclarePairedDelimiter` from `mathtools`.

The rule of TeX is that anything that is written in TeX is instantly old. Because people don't read what Knuth had in mind. TeX was the prototype not the production grade product. Still people refuse to get the message.


Well, Knuth still writes all his stuff using "plain" TeX. For example, the source of the TeXbook and the METAFONTbook are both TeX, not LaTeX or whatnot. Granted, he did create TeX, so he's probably more comfortable with it.


Pure TeXnicians are a thing. Besides, what do you expect him to use? it's his creation.

The point is he created TeX for himself and expected others to supercede it with a proper implementation. Didn't happen though.


  \DeclarePairedDelimiter\abs{\lvert}{\rvert}
Isn't this better than newcommand? This makes both \abs{x} and \abs*{x} valid.


I use Zotero with the better bibtex addon. Works great. When I first started using zotero, I imported my existing bibtex library, so all my existing bibtex keys all worked. I use zotero as my library for everything and add bibtex keys to things I cite.

https://retorque.re/zotero-better-bibtex/


I 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?"


> 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.


What 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.


Asciidoc, 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.


The way I see it, this only proves my point. As you write: '...None of them have become the standard...' and this is at the center of the argument. TeX may not be ideal but it strikes the correct balance to become and stay standard for so many years. One can do pretty much anything in bare Postscript (and I am ashamed to admit, I have) or even 'handmade' PDF but it does not make it a good alternative to TeX. I have experimented with alternative syntaxes (apologies it this is not the correct plural of 'syntax') but had to give all of them up due to a number of flaws. These experiments gave me a new appreciation for Knuth's choices.


I disagree. I think Latex will soon become legacy like Cobol.

HTML and CSS basically do a lot more than Latex does - except for maths things - and are far more widely known, and far more forgiving. Also importantly, they support hyperlinks, animations, and inline interactive scripts. It seems that HTML and CSS with the appropriate CSS styles and shorthands (like Markdown) could eat up everything that Latex does and much more. I don't know if Latex can survive the onslaught.


I have heard HTML/CSS mentioned as an alternative and I pray every day this time will never come. Even taking all the complaints leveled at LaTeX at face value, using HTML/CSS looks like pure hell to me. Allow me to elaborate.

1. You mentioned forgiving. One may not like the style of TeX error messages but its tracing facilities are extensive and given enough time and perseverance one can track nearly any layout issue down an correct it. Compare this to CSS silently ignoring incorrect syntax, having different syntax across browsers, etc. I would take strict syntax checking over this mess any day.

2. Many complained that LaTeX has more than one way of achieving the same result. True but how many ways are there of centering a div on a page? I can list six off the top of my head and there are probably more.

3. You casually mentioned '...except for maths things...' but this is far from minor. I cringe when I read engineering papers not written in TeX: the formulas are so ugly that they border on unreadable.

4. CSS may be wider known but unlike TeX CSS is a moving target. Being designed by a committee it carries all the flaws, like kludgy design in the name of 'compatibility', poor choices of syntax to make it appeal to a wider audience, etc. The designers of CSS are so enamored with the 'cascade' but in practice it is rarely used as intended. The 'important!' kludge as a perfect testament to this.

5. LaTeX syntax may be unappealing to some but HTML takes it to a whole other level: whitespace that affects the layout yet no easy way of getting rid of it (HTML style comments are a torture device); too verbose... one may not like the backslash but what about <...> </...> ? Five extra symbols!

6. LaTeX engines produce full featured PDF so hyperlinks are not a problem (most LaTeX documents have them). Yes, CSS has so called 3D graphics but it is anything but programmer friendly. What good are 3D transforms if one cannot even use simple lighting effects programmatically; c'mon, at least give me Lambert reflection! Incidentally, inline JavaScript can be included in pdf documents produced by LateX as well (although ... why?)


> I think Latex will soon become legacy like Cobol.

LaTeX’s usage has only increased with the creation and growth of the web. What makes you think it’s going anywhere?


Academia has got inertia. How long has it taken it to adopt Open Access? There's far more investment into web tech than into Latex. Browsers can do more than PDF readers.


The “except for math” part is doing a lot I think. There’s a huge amount of work needed to get rendered math to look as good as latex’s and I’m not sure CSS (as an example) is expressive enough to get this done


Or HTML syntax will become legacy

People are write something like Kotlin html dsl


How many of those rely on LaTeX syntax extensions to render equations?


The LaTeX formula language is a separate thing from the rest of LaTeX: It's become the standard for formulas. There are some editors that can speed up writing those formulas. Asciidoc also offers an alternative formula language.


I can't speak for most of them because I haven't used them, but I know that TexMacs doesn't use LaTeX under the hood.


None of those are a complete replacement, except maybe Lyx, and it’s based on LaTeX.

> HTML and CSS have practically replaced most non-maths uses of Latex.

Huh? You must be totally ignorant of the uses of LaTeX.


This comment makes me see red.

First of all, this:

> None of those are a complete replacement, except maybe Lyx, and it’s based on LaTeX.

Source: Your [censored].

> Huh? You must be totally ignorant of the uses of LaTeX.

Outside of academic papers and books, what?


> It is telling that no real alternatives have emerged during the 40+ years of TeX's existence.

But what does it tell you that such an ugliness remains and the way to fix it is relatively unknown? It surely can't be a pro-TeX tell!


It tells me that beauty is in the eyes of the beholder, i.e. what one may perceive as ugliness, countless others will view as beauty or, at least functionality. I personally think that the ugliest design in existence is Python but I admit my opinion is not common. Moreover, I use Python myself, since syntax is not the only important thing in a language (the ecosystem is Python's undisputable strength). It is also unclear to me what specific 'ugliness' in TeX is fixed by, say TeXmacs. Is TeXmacs internal language dramatically (or any) better than TeX? Does not seem so. The WYSIWYG option? There are WYSIWYG editors for TeX as well.


"here are WYSIWYG editors for TeX as well." not there are not. Apart from TeXmacs I know of no editor which give you on the screen the same result you get on the paper. LyX has not such a feature. If an approximation is ok, then fine, but I do not think you can call it WYSIWYG. Is something else. And it requires a lot of work to do it correctly. You should at least appreciate the technical merits, even if you prefer to use LaTeX for its ecosystem. But as a user of both I see the clear merits of TeXmacs in terms of quality of my work (mathematician), I can focus more on what I'm doing, instead on deciphering the mess of the LaTeX formulas and try to find where to put a correction. I can give online lectures with it, discuss on zoom while scribbling on a TeXmacs document, much of the work I was doing on paper I do now directly on the computer. To me there is a clear difference in the user experience between TeXmacs and LaTeX and I will never go back to write LaTeX if I can help it (I do it sometimes, if my coauthors are using it and do not want to try otherwise).


As a fellow mathematician you may then appreciate the fact that local and global maxima may differ dramatically which pretty much precludes true WYSIWYG (not just in TeX) in that you have to settle for one of the two: visual output with suboptimal aesthetics (TeXmacs, and, to some extent, LyX) or perfect results that you have to compile with some delay. It has nothing to do with the computational power available but rather with the occasional highly unstable line breaking. Even in MS Word it is annoying sometimes to see it resize a current line even though it uses a rather lame line breaking routine. TeX does have facilities for almost real time WYSIWYG (SyncTeX was added specifically for that purpose) although they take some effort to set up. As far as concentrating on the work at hand I have written whole papers without compiling the document once before everything was complete. I admit it takes some getting used to but I prefer something I can grep through to a mere pretty picture. I admit if my work was heavy on large commutative diagrams I might have had a different view. One thing I totally agree with you on is that TeXmacs is an outstanding piece of software. I would just prefer to keep my documents in TeX (which TeXmacs can export, kinda).


> visual output with suboptimal aesthetics (TeXmacs, and, to some extent, LyX)

Till now I took the developers word that the aesthetics of TeXmacs is better than the one of TeX and I would be curious to know where the opposite is true (and in case also why this cannot change)


From what I have seen in TeXmacs documentation, they have implemented pretty much every feature of TeX's linebreaking algorithm and more (microtypography, global page breaking, etc) so my claim above was not to say that the documents TeXmacs outputs have suboptimal aesthetics (to be fair, modern versions of TeX have all of these features, as well, although not the original TeX, alas). What I meant to say was there is no (even theoretically) possible way to have a perfect WYSIWYG editor if global paragraph/page breaking is desired. For example, due to global page breaking, one may be editing a line in the middle of the document and its position on the page (and the page number, left/right headers, etc) will be constantly changing---not good for the visual experience. I do not know how TeXmacs deals with these (extremely rare, admittedly) cases but the discussion was about the true WYSIWYG vs not so take it with a grain of salt. Let me say this again: TeXmacs is an outstanding piece of software. If in thirty years, a TeXmacs file format is still readable by the newest version (possibly with some easy tweaks), I will consider switching from TeX :). My other (minor) concern is that the LaTeX files that TeXmacs exports do not render at all as the pdf files TeXmacs produces itself. So as a WYSIWYG frontend to LaTeX, TeXmacs is ... not quite. Which they never claimed to be so I cannot fault them for this.


In my experience, that’s not entirely true. Some of my mathematician friends claim that they (and other people they know) often rather read the source code than the type-set result. I’m inclined to believe it because the biggest problem with LaTeX (to me) is jumping between the source and the result while editing, especially when formulas are involved. (Syncing tools help, but they’re far from perfect.) So it is often more convenient to just work with the source but this leads to problems where mis-typeset formulas don’t get recognized because too little time is spend with the result and they look fine in the source. And then people start reading the source code of other people’s papers because it’s more understandable, making the whole thing absurd.


> you have to think of the results, not the source

You can. But it's equally valid to look at the source and say "this should have been replaced long ago"

Which is really has, except for tiny markets.

No reason it can't be improved on drastically.


but the source is the problem. When you work with 100+ latex files and it is so difficult to reuse the code and every variable is in a giant global scope, you would waste so much time just to trying to figuring out how it works.


> 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

I cannot think of the results separately from the source. I am not wired to appreciate Potemkin beauty.


In 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.


Until you have to change, quote, or re-use parts of it, in another document.


There are tools (i.e 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.


As 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.


MathML 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.


I 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.


I 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?


I 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.


I don’t have an opinion about whether they’re better or worse, but have you tried groff or heirloom troff?


How is Quarto? It uses Pandoc Markdown.


There was a discussion about that last year [1]

[1] https://news.ycombinator.com/item?id=30042831


Generally 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


TeX 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.


I 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.


LaTeX 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".


Well no, but LaTeX should be backwards compatible with TeX so there's always that option.


Great 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.


Realized 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...)


My 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.


It 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)


For the terminal output issue, consider latexrun https://github.com/aclements/latexrun


You're crapping on a thing that Knuth and friends made and gave you for free.

Are you about to go write something better?


I 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.


Many 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).


To 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.


> 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.


> 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.


check out MonsterWriter


Just tried it. Does it support theorem environments?


Some 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.


It also doesn't mention the spacing after the dx. You need spacing afterwards, but also not unconditionally if the thing afterwards also has a space before (that sounds obvious but I can imagine a macro that has \,\mathrm{d}#1\,).

There is a better way to do this, which is to use LaTeX's built in spacing adjustment, which is different around different types of object (e.g. notice how ab+cd already looks right). To do that, use: \mathop{\mathrm{d}#1}

Even if you carefully do the "right thing", the spacing in LaTeX is by no means perfect. E.g. just look at f(x)g\left(\frac{x}{y}\right) - it looks like g is more associated with f's arguments than its own.


Thanks for flagging the image issue, I think there's an issue with the responsive image serving code that doesn't work consistently across browser. Temporarily disabling that for now & pushing a new update.

Also, you are right about using \mathrm{d}x. Another friend also just flagged it to me as well, I will update the post regarding this!


FWIW there is an ISO Standard:

> ISO 80000-2:2009 > Quantities and units — Part 2: Mathematical signs and symbols to be used in the natural sciences and technology

https://nhigham.com/2016/01/28/typesetting-mathematics-accor...


the [physics package] (https://ctan.org/pkg/physics) provides for differential with a \dd command with a roman d, it also has several other useful macros


In physics, it's \mathrm dx. In mathematics, it's dx.


Historically, 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.


Not 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.tex...), page 13, the dω is italic. In Klein's Lectures on Mathematics (1894) (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), the dx is also italic.


It 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

TIL


In my mathematics is \d x .


?


TeXmacs 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.


TeXmacs 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.


A 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.


I 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!


Is there an equivalent of \NewCommand in TexMacs? I can't find anything by Googling.


TeXmacs has its own macro language. The equivalent of \newcommand is \assign together with \macro (yes, TeXmacs has proper first class macros, like any respectable language, e.g. Lisp). And macros arguments can be edited visually, here's an example: https://twitter.com/gnu_texmacs/status/1251554336842407938


you can check also the manual which comes with the program, in the menu Help->Manuals.


There is a good introduction in Chapter 12 of The Jolly Writer: https://www.scypress.com/book_info.html


Does 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/


One 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.


It only lives on through cut and paste previous latex files and stack overflow lol


#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}$


I 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


Is 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.


There 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.


> 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.


since a macro is just a macro, isn't it fairly easy to just inline the macro's then?


One 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.


Not 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.


The 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://tex.stackexchange.com/questions/35/what-does-overful...

https://tex.stackexchange.com/questions/138/what-are-underfu...


> The linked post is not a comprehensive manual of LaTeX but just a collection of typesetting tips that the author found interesting.

I realise that, I suppose I was partly joking, but partly did assume 'common mistakes and advice' would mention it; it's extremely common.


Yeah! When I make my book into PDFs, I get a ton of those yet see no issues visually.


If you look carefully, you should be able to see that the mentioned line slightly overreaches the edge of the page.


Slightly off-topic question: any suggestions for modern presentation LaTeX themes (besides Metropolis, https://github.com/matze/mtheme)?


LaTeX 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.


Just 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.


It is not exactly a picnic in Word either though....


If this article gets even one author to stop using < and > when they mean \langle and \rangle, it will be worth it.


Usw 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.


Wish 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.


In 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.


I 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.


Great cheat sheet, not enough folks know about \mid and friends.

Once you’re in nyc let’s grab coffee sometime!


Thank you! :) and sure!


The final point, involving labels and references, could be improved by mentioning cleveref: https://ctan.org/pkg/cleveref?lang=en


I 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.


Overleaf (https://overleaf.com/) is pretty popular for this, and also tracks things like edit history


Unfortunately, it doesn't allow you to bring your own editor, so I have to put up with its half-assed implementation of Vim.


It 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


Have you tried overleaf?


Something like overleaf.com ?


Latex and Tex, my goto language for beautiful documents.

Try rewriting Knuth's books with markdown.


Several of the images are broken links. Perhaps an example of Muphry's Law?


Refreshing might help (my guess is it might be due to img fallback issue), thanks for flagging this and I'll be investigating!


Should be fixed now. First time hearing about Muphry's Law, definitely gave me a chuckle!


Works 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.


> First time hearing about Muphry's Law

It was probably a mipsrint.


Nope.


I knew that, was just playing the joke back. I guess it misfired. Or maybe not.


I missed it.


Anyone know of any good typesetters who I can hire to typeset an ebook?


I'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-professiona...


Maybe 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 (–).


Ah, 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?




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: