# What is the difference between a typesetting language and a markup language

I remember, I read some article in a technical journal where the author drew the attention on the reader on a lot of people confusing typesetting languages and markup languages.

How can I surely tell if a language is a typesetting language or a markup language?

As far as I understand TeX is a typesetting language and LaTeX implements a markup language atop TeX. Is this a correct way to put things?

• a typesetting language will provide instructions to do things like explicitly specify fonts, spacing, and similar elements. a markup language will provide the means to identify what is to be composed, e.g. section headings, display math, etc. tex is definitely a typesetting language. latex is rather a hybrid, as it encourages the identification of logical elements, but also provides the ability to drop into the niggly typesetting details, and some users prefer to work at that level. a true markup language doesn't allow that freedom. – barbara beeton Sep 23 '14 at 19:56
• @barbarabeeton Things like HTML (at least, old, pre-CSS, HTML) tend to blur lines a bit, because they contain a lot of concrete elements (fonts, distances, etc.) Is old HTML something like “an impure markup language”? – user40989 Sep 23 '14 at 20:06
• you're correct about "old" html -- and even the current flavor -- being more-or-less hybrids in the same way as latex. i was thinking of sgml or xml with the requirement of a dtd to "keep them honest" (and cut down on the ability to escape from the strait-jacket). and other (unrelated) markup languages existed and were in use by publishers/composition houses before the internet was available to the masses. – barbara beeton Sep 23 '14 at 20:10
• @barbarabeeton I don't quite understand the basis of the distinction. Isn't it a matter of degree? Presumably you could have a language which enabled you to, say, place different size dots and lines on a page. In comparison with that, TeX would look like markup. (After all, TeX allows you to say use such-and-such font in so-and-so size with such-and-such skip and so on. You don't have to tell it to draw a line of so many em with a dot on to make an i.) Obviously this is an exaggeration but is there really a cut-and-dried distinction here? – cfr Sep 23 '14 at 23:47
• @cfr -- i'm probably being pedantic here, but my point is that tex natively provides only the typesetting primitives directly. it does also provide the tools that allow you to create your own markup "front end", which i suppose does beg the question; other typesetting languages usually require separate mechanisms to develop a markup wrapper. please don't confuse plain tex with the tex program; in the sense i'm referring to, even plain tex is a front end, albeit quite limited. – barbara beeton Sep 24 '14 at 12:58

As far as I understand TeX is a typesetting language and LaTeX implements a markup language atop TeX. Is this a correct way to put things?

yes, this is accurate, as well as concise.

a typesetting language provides the tools to convert an input stream into what is output on a surface. among the tools are

• access to fonts, and commands to select and/or switch between them
• commands to move along the surface in various directions
• a mechanism to break an input stream into lines or paragraphs, and the result into pages
• commands to apply the "basic" commands in a more efficient manner

as an example of the last point, one very valuable feature in tex is the concept of grouping. this is not present in other typesetting software i've used. for example, in one such system, there was a command to raise a superscript to the proper height, and a "reverse" command to step back out of it by the same distance. (it didn't always put one back at exactly the original baseline.) tex, on the other hand, stores the original values when a new group starts, applies the local values for the group, then forgets the local values and restores the saved values.

a markup system, on the other hand, identifies material according to its function or structure, not how it should look on a surface. thus there are identifiers for "title", "author", "chapter", "section", "theorem", etc., and these are converted at processing time to use appropriate typesetting commands. this structural markup permits easy switching of output format, provided a common vocabulary and syntax are used. latex and xml are two examples of markup systems. neither can be used without "back end" support. in latex, this support is integral, while xml requires separate tools; however, what is identified in both cases are the structural elements, not the final appearance, hence "markup".

• Thank you a lot for your insightful comments and answer! (Happy new year!) – user40989 Jan 9 '15 at 17:18