When I ask questions about achieving some particular layout with LaTeX, I get answers that suggest I should use constructs that don't make sense for their semantics. For example, I wanted to indent a single paragraph, and I was told to make it a list with no bullets. It works, but that isn't the semantic meaning of a list, so why is it acceptable to abuse it like that?

We stopped doing it in HTML over a decade ago. Why are we still doing the equivalent of table layout in supposedly the best typesetting system there is?

Am I not getting it, or isn't this a little inelegant? Everyone says LaTeX is elegant and that you don't need to worry about layout, but then I find myself contorting tables, lists and other semantic markup to put stuff where I want it. Does the emperor have no clothes, or am I not getting it?

  • 13
    Because layout in LaTeX is broken by design? – Khaled Hosny Dec 31 '10 at 14:45
  • I understand that I should not be doing my own layout, and that it should be in a stylesheet - but if that's the case how come nobody does it like that on forums, in tutorials etc? – Bob Bobson Dec 31 '10 at 14:49
  • 10
    I'd say one should be more willing to tolerate "unsemantic" markup in TeX than in HTML, because with HTML, the markup is all there is, but with TeX, the markup is only a means to producing the final output: a rendered document that has no trace of any semantics beyond the presentational. (That said, if you find yourself contorting tables and lists all the time to get what you want, you should probably be defining your own newcommands for those things.) – Rahul Dec 31 '10 at 14:57
  • 1
    I think the reason is that when you're using lists, what you use is something that was defined as an indented sequence of paragraphs (may be bulleted, may be numbered) way back in time. As it is something people uses a lot, it got its own basic LaTeX command. You can define a ``\indentedparagraph` using the list environments or using TeX primitives, but with the latter, you would be redoing previous work. – fabikw Dec 31 '10 at 15:27
  • 1
    I would argue against @Rahul Narain's opinion that we should tolerate unsemantic markup in TeX on the grounds that, frequently, TeX sources are used to create a variety of outputs, e.g. presentation slides, online pdfs with links in them, print, as well as (via conversion tools such as latex2html) any other form, including HTML. Strict adherence to semantic markup would help immensely the portability of TeX code to a variety of output formats. – Andreas Dec 11 '12 at 22:06

When a problem like this comes along, and the answer is to use something that doesn't really make semantic sense, what you should do is create a new environment or command that wraps the functionality in a way that makes semantic sense.

Every layout language has this problem -- somewhere along the line, you need to get down to a physical, non-semantic solution. In HTML, the non-semantic parts of the solution are now pretty-well covered by CSS and JavaScript (which are different languages from HTML). You create <div>s and <span>s that capture the semantics, and then you use CSS and JavaScript to define the physical layout for those semantics.

In LaTeX, you simply wind up using the exact same language for this purpose: LaTeX (or plain TeX, which is often hard to differentiate from LaTeX).

  • 4
    Exactly, this is the answer: just define a new command or environment that makes semantic sense. – Juan A. Navarro Jan 24 '11 at 11:04

Before the hijacking of the word semantics by web standardistas, there was a need recognized by the CSS developers to separate content from presentation and this they have managed to achieve to a large extent. Following years of developers slicing images and placing them into tables it was a breath of fresh air that not only machines, but also humans could read the HTML code. At about the same time the word semantic took another tint, this time being associated with accessibility and the ability of screen readers to translate the mark-up for readers. To achieve all these a jumble of technologies got all mixed up, CSS, HTML and its ugly cousin XHTLM, JavaScript, PHP, python etc.

To make it worse we now have the Semantic Web which is a group of methods and technologies to allow machines to understand the meaning -- or “semantics” -- of information on the World Wide Web as coined by Tim Berners-Lee. He defines the Semantic Web as “a web of data that can be processed directly and indirectly by machines.”

So where does TeX and LaTeX stand in all these? You can make it as semantic as possible. For example the following TeX code is very semantically’ correct.

  Lorem ipsum etc

  Another paragraph of Lorem

LaTeX is a different story, in that first and foremost is a system for structured documents. Its commands generally at the user level are very semantic and part of its strength.


is as semantic as you will ever get any other mark-up language! By just being careful in your texts, you can ensure that they are both semantically correct and readable. Certain mark-up will always contain some form of presentational data similar to problems with HTML, but by being careful in your definitions you can avoid this. Call a colored box \colorbox{} rather than \redbox and use \emph rather than \textit. This is easier said that done though. Consider the following:

  The evidence is, \textit{prima facie}, convincing.


  U.S.S. \textit{Philadelphia}, U.S.S. \textit{Alabama}.

Perhaps one can define a semantic macro for ship names and using \ship{}, but what about prima facie where does one stop?

  • 3
    That's a nice history. I do disagree with some of your value judgments, but still a good answer. – TH. Dec 31 '10 at 15:41

Bob, one thing to consider is that LaTeX2e has been around for 15 or so years. Remember what HTML was like 15 years ago?

I think you're absolutely right about the over use of tables. You see it all the time. One great example of a place that's absolutely not a table but is implemented as a tabular is the list of authors with the standard classes. The \and macro is absurd: It ends the current tabular, adds some spacing, and then starts a new tabular.

I suspect that LaTeX3 will be a lot better with respect to these sorts of issues. But that said, there is a down side to adding a semantic abstraction—that is, another layer of macros—which is that bugs become a lot harder to diagnose and fix. For a simple example, how many times have you seen \vspace{-.5ex} or similar to try to fix up some spacing problem caused by using the semantic macro provided by some package? It's a definite trade off.

  • 13
    A few LaTeX3 comments here. First, we've still got to get it written :-) Secondly, at some stage you have to turn semantics into something you can typeset, so it's a question of where that happens and how you describe the lower levels. For example, a lot of stuff currently uses the list environment, which is badly mis-described. Thirdly, what is needed is better separation of design parameters from semantics. That should give us a better way of dealing with the problem you highlight. The LaTeX3 Team are aware of all of this: we are working on it, honest! – Joseph Wright Dec 31 '10 at 17:01
  • +1! Two of the most absurd (ab)uses of list is center/flushleft/flushright and theorem & friends. This is a dirty hack! – mbork Mar 10 '12 at 19:54
  • I don't see how LaTeX3 can really achieve this kind of seperation of semantics without radically breaking the whole TeX model and spliting documents into a semantic and typesetting section. Just as with HTML TeX faces the problem that semantics don't uniquely determine how the output should look. If you intermix the typesetting directives with the semantic content you lose the benefit of expressing things semantically. So, like HTML, you need a separate document (CSS) that can decorate the semantic content – Peter Gerdes Jul 18 '15 at 6:49

Because TeX is an awful outdated document markup language.

More or less TeX was written to do the simple job of controlling document layout. Knuth delibratly resisted making the original macro processing Turing complete as he felt that there was an unfortunate proliferation of Turing complete configuration languages everywhere. Indeed, I kinda wish he hadn't and TeX code was primarily produced as an intermediate protocal between a high level layout language and the backend renderer.

Unfortunately the installed base now is just too large to toss TeX over and use something else. Many of the mathematicians I work with haven't even made the switch to latex yet and use plain TeX out of habit. However, I have high hopes that the LuaTeX stuff will gradually begin to bring TeX to the point where it's a decent markup language.

Sadly producing semantically meaningful documents in TeX is just WAY WAY too hard. Even parsing multiple optional arguments is something beyond virtually all TeX users much less coding a semantically meaningful macro to express their new notation. I've tried to do this in my rec-thy package for TeX but surely haven't succeeded.

  • 4
    I'm curious what you mean when you say that Knuth resisted making the original macro processing Turing-complete. TeX today is certainly Turing-complete. I'd love a historical reference, if you have one. – TH. Feb 11 '11 at 9:39
  • Can't remember where I saw this...I think it was in either a TuG article or one of the standard LaTeX documentation. Anyway I'm just replying to indicate that I don't remember the source and others should use google themselves to check the veracity of the claim. It could just be someone linking together a remark Knuth made about too many programs being Turing complete with properties of TeX but I thought there was something more in one of the Leslie Lamport books. – Peter Gerdes Aug 11 '11 at 18:32
  • just out of interest, what markup language do you suggest over LaTeX for document layout? I'm a TeX lover, yet I'd be interested in other methods of typesetting (mathematical) documents. Something that a programmer can adhere to more (e.g. for loops are not so contrived as they are in tex). I haven't looked into LuaTeX yet, but maybe I should? – romeovs Mar 10 '12 at 16:30
  • I don't think there is a good option because it would be a substantial effort to create requiring hundreds of subject specific experts w/ no monetary return. Having said this mathml makes a little headway. The key thing is to separate the material into three seperate parts: 1) The semantic content. I am applying the concatanation operator to strings foo, bar or I am using this symbol as a variable ranging over holomorphic functions. 2) The display of that semantic content (css for math). 3) 1,2 should be dumb and have a programming layer designed (as js is for html/css) to manipulate. – Peter Gerdes Sep 14 '13 at 2:40

Your Answer

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

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