Hacker News new | past | comments | ask | show | jobs | submit login
What is LaTeX and Why You Should Care (defmacro.org)
135 points by s-phi-nl on Aug 3, 2010 | hide | past | favorite | 77 comments



I procrastinated quite a bit when writing my master thesis by trying to make it as beautiful as possible. Take a look to see what's possible with LaTeX: http://www.duo.uio.no/sok/work.html?WORKID=81971&lang=en. The source is available here: http://bitbucket.org/uggedal/thesis


Would like to convey some belated but serious gratitude for this. When I was working on some heavy-duty LaTeX academic publishing a year or so ago, this was one of the few available resources for full source code of a serious, professional-looking, non-math document. I find it incredibly helpful and inspiring.

As a side note, I am always amazed at the playful-but-ugly aesthetics that are common in the TeX community. While talking about having a professional-level typesetting engine, TeX-related publications are frequently painfully ugly. It somewhat undermines the cause.


Very nice layout. Not very "academic looking", but really nice to look at :)


Did you print this in color? Did you actually have graphics and screen shots in the paper? Academy changed (improved?) since I last read academic papers.


Yes and yes.


like the side notes. they make reading footnotes seem stressful by comparison.


The source link 500s. I'd like to see it.


Bitbucket had some issues due to EC2 network outages yesterday. Should be back now.


"Feil i databasen" - that doesn't sound good and I can't see anything there.


Seems like I've crashed the publication database of the University of Oslo. "Feil i databasen" translates to "database error". Seems to be fixed now.


Now I get "database error" in English. Progress!

http://www.duo.uio.no/sok/work.html?WORKID=81971&fid=407...

Update: ... and now it works, finally :-)


How appropriate, I just finished a paper today and submitted it for review. LaTeX is awesome and sucky at the same time. On the awesome side, you have structure separate from formatting. This comes with lots of benefits as mentioned in the article. It also allows you to use the concept of imports (or includes if you will), so you can have a well factored paper. It also allows you to do sane things like footnote, cite and reference diagrams and sources without a need for explicit number tracking -- just give everything a unique identifier that works for you. Finally if you do well enough with your structuring you can output not just different file formats like pdf or ps or whatnot, you can also output completely different styles. It is pretty simple to wrap your core with the trappings of IEEE style for one version and a book-like style for another.

On the sucky side, the toolchain is notoriously difficult and cryptic. For some reason you have to make multiple passes of various tools by hand (or with a makefile -- i reccommend http://code.google.com/p/latex-makefile/ it just works). The syntax can be a bit inconsistent. The worst is the errors tho, sometimes it is impossible to figure out why all your figures are showing up at the end of the document instead of in-place, or why all your references are failing to point at anything.

Overall tho, it is a fantastic system :)


I've started using org-mode to write my papers, then convert to LaTeX. Not perfect, but I find it's more natural to write in org-mode and helps me focus on the content instead of drifting off onto the internet to research macros. (Now I can drift off to read HN instead, a vast improvement in non-productivity.)

I've started thinking of TeX as the assembly language of document formatting, LaTeX as C, and org-mode as... pick your favorite higher-level language here, I'll go with Python.

Not a perfect metaphor, but in terms of paper productivity it feels that way.


  > I've started thinking of TeX as the assembly language of document formatting
I remember having read a Knuth interview saying exactly that's what he intended TeX to be. He was also surprised that everyone settled for LaTeX instead of creating their own TeX dialect designed specifically for their own needs.


  > Not perfect, but I find it's more natural to write in org-mode 
Do you have any specifics on the problems you faced? I produced my master thesis entirely using orgmode without any problem. (defined custom latex class, with different kind of ToC etc, not that difficult)


I suppose it depends on what you mean by "problems". I don't think org-mode is coming up short in some fashion.

Org-mode is great for structural editing and tables, and simplifies some aspects of LaTeX (images, for sure). I still find myself "dropping down" into LaTeX. I don't think it's an inherent weakness in org-mode, it's just that now I keep track of org-mode and LaTeX commands.


I've not tried org-mode, but I've started using Markdown with pandoc (http://johnmacfarlane.net/pandoc/) to do much the same thing. Markdown makes actually writing much quicker and more readable, but you can still insert raw LaTeX where you want to do something extra (e.g. \cite).

Additionally, Markdown is far less threatening to technophobe collaborators. I've successfully written grant applications with clinicians using Markdown in an etherpad document (free hosted version at http://piratepad.net/), which I later converted to LaTeX/pdf for submission. They would never have put up with writing lists or headings in straight LaTeX.

EDIT:I should have stated that pandoc is a nice tool for conversion between a bunch of formats including Markdown, Latex, Html, s5, reST, RTF, epub and a few others. In response to the comments below about conversion to word always sucking, pandoc provides the least sucky attempt I've found so far.


I tried using LaTeX with org-mode as well, but I've found that writing a paper / permanent document in LaTeX feels more natural than doing so in org-mode (org-mode being more suited to taking notes).

I did use LaTeX to take notes all through college and it has certainly helped ingrain it well into my muscle memory.


Could you post a sample source in org-mode, the Latex it produced, and then the final pdf? I've tried going through documentation to get a feel for it, but everything I've found focuses on features in isolation, and are not focused on using it to write full papers.


Not my work, but something I found after having my curiosity piqued by this thread: http://www.mail-archive.com/emacs-orgmode@gnu.org/msg04582.h... . And here's the blog post that led me to it: http://www.mfasold.net/blog/2009/02/using-emacs-org-mode-to-... .


Can you automatically convert from org-mode to LaTeX?


M-x org-export or C-c C-e brings up a menu of options for export, including HTML, LaTeX, and Docbook. The org-mode manual has good information:

http://orgmode.org/manual/LaTeX_002fPDF-export-commands.html



This is interesting. How do you do your conversion?


M-x org-export-as-latex


You probably know, but the reason there are multiple passes is because once a page is typeset, you can't go back and "fix" it. TeX is very page-centric. So references, for example, aren't "knowable" until you've typeset all the pages. Then the next pass goes through and updates the forward references.

It could be done another way, but in the era that TeX was developed, it would have required more memory than was realistically available most of the time. I find that once I've run it twice, I can get away with single runs usually after that until I'm ready for the "definitive" version. Until then, I'm less concerned with whether the cross-reference is right, than whether there is a cross-reference in that location at all.


You know, gcc uses multiple passes, too, internally. If gcc were to use latex's model, you'd have to run it multiple times to get a working executable. Mind you, it would produce an executable every time, but those first ones would just crash. Latex can produce some nice looking documents, but as a technology, it's shoe strings and bubble gum.


The only problem is that the cross-references may be out of sync. This is usually not a serious barrier to readability.

Another gcc analogy is a dependence on a third-party library whose API keeps changing. Then you'd have to run gcc once to regenerate the library, and once on the client using the library.

Peeling that back a level, the analogy is between files like libfoo.a and foo_defs.h (for gcc) and files like section1.aux and document.bbl (for latex).


LaTeX will warn you when the references are out of sync, and there is no reason why it can't make a second (or third) pass internally without having to call (pdf)latex manually again and throwing .aux .log .other_random_stuff files everywhere.


So whip up a shell script and call it "better_latex" mark it +x and call the real exe multiple times. Now it's an improved version that does it internally, just like gcc


I just use LaTeX-Mk or a similar package, which takes care of multiple runs of LaTeX fairly well.

http://latex-mk.sourceforge.net/


After using (and writting) several ugly Makefiles for compiling LaTeX, I discovered rubber (http://www.pps.jussieu.fr/~beffara/soft/rubber/) and never looked back. It is packaged at least in the standard Ubuntu and Fedora repos.

I use the following Makefile wrapper around it:

    DOC = memoria

    all:
            rubber --pdf $(DOC)
    clean:
            rubber --pdf --clean $(DOC)

    .PHONY: all clean
It handles biblography, knows how many times recompile and discovers dependencies.


I took a look at the Makefile, and I'm not entirely comfortable using it while not knowing exactly what it's doing. I normally don't require to know and have control over everything, but with Latex, the less unknowns I have, the better I feel.

This is what I've been using, inherited from a colleague/committee member/friend:

  PAPER = paper_name
  SECTIONS = $(PAPER) abstract introduction design results conclusions

  default: $(PAPER).pdf

  $(PAPER).bbl: $(PAPER).bib
          pdflatex $(PAPER).tex
          bibtex $(PAPER)

  $(PAPER).pdf: $(PAPER).bbl $(foreach SECTION,$(SECTIONS),$(SECTION).tex)
          pdflatex $(PAPER).tex
          pdflatex $(PAPER).tex
          pdflatex $(PAPER).tex

  clean:
          -rm -f *~
          -rm -f $(PAPER).aux $(PAPER).log $(PAPER).out $(PAPER).bbl $(PAPER).blg
          -rm -f $(PAPER).idx $(PAPER).ilg $(PAPER).ind $(PAPER).dvi $(PAPER).toc
          -rm -f $(PAPER).pdf


For a remedy to the "sucky side" if you have a mac + TextMate, it all _just works_. You do everything you would normally do, and then hit cmd + R which will run the typesetter.

My buddy during my undergrad used LaTeX, at the time the thought of debugging my documents seemed insane (though he could do some amazing ninja stuff like rebuilding his graphs in matlab and importing them on build). Since starting my masters, I've taken it up, and yes it is awesome.


Even better, use LaTeX watching (ctrl-cmd-w) with a pdf viewer that supports pdf sync (like Skim) and the output updates every time you save.


The latex mode in TextMate is really awesome :)


You can do "imports", and you can also factor anything that's repeated into macros. The problem is that the lack of namespaces and weird scoping rules are so antiquated that it's painful to use when I know many programming languages that do the job far better.

On the other hand, it does support currying of macros!


For those using a windows environment I find TeXworks (http://www.tug.org/texworks/) is an easily installable TeX environment.


I use rake-latex for my workflow, which is also pretty awesome: http://devel.softeng.ox.ac.uk/trac/softeng/wiki/Utilities/Ra...

My main TeX annoyance is tables, but I don't think anyone has come up with a decent way of expressing them in a textual manner.


It always blows my mind that someone (a philanthropist or the government) hasn't just thrown down a few million bucks to make a truly user friendly version of LaTeX. The amount of grad student and professor time wasted dealing with the flaws in LaTeX is mind-boggling.

Or am I naive in this cost estimate? Does anyone know roughly how much money and developer time went into the currently best editors, like TeXShop and TeXnicCenter?



Speaking as a grad student who has been reading a lot of papers/theses lately, we can tell if you used LaTeX or Word, and if you used Word we mock you for your ugly fonts and amateurish layout.


Grad students mocking people? Now that's something new.


They don't pay us enough to be nice. We're allowed to be bitter. :)


Most research papers typeset using LaTeX use ugly fonts as well -- the computer modern fonts. In fact, when it comes to presenting equations, even major publications use these ugly CM fonts. They usually use Times Roman for the text itself. The mismatch is horrible.

There is a reason why there are people specializing in book design. And LaTeX specifically encourages ignoring presentation.

[But overall, I agree. Word documents tend to look even worse, unless formatted carefully]


Computer Modern is ugly? I guess there's no debating taste. I find very readable and quite good looking. It does tend to look much better on paper than on-screen though, because of the thin lines, and I agree that the pairing with Times is pretty bad.


Computer Modern is good for math books, so that's why we tend to like it. But try to use it in other areas and you'll see how readability suffers.


I'm glad to know that I'm not the only person who thinks CM fonts are ugly!


I only wrote one thesis and I did it in Word. Most of my publishing since then has been in WordPress.

Is learning LaTeX anywhere near as useful to a professional developer as say learning vim or emacs?


> Is learning LaTeX anywhere near as useful to a professional developer as say learning vim or emacs?

I would say no (even though I use latex nearly every single day).

On the other hand, it is indispensable if you're doing maths or anything that involves lots of formulas, citations, footnotes and what not, because it decouples the structure of the document from the formatting.


There's learning LaTeX, and then there's learning it. I think it's safe to say that most paper authors only need to find the appropriate template/example document and fill it out with their content. Once you figure out basic font modifications (bold, emphasis, "typewriter" (monospace)), tables (easy), and images (also easy), you're pretty much set--that's about the limit of my experience with it. Now, I've only had occasion to use it for some math-heavy crypto assignments, a few IEEE-format papers, and a thesis proposal, but in each case I was able to accomplish what I wanted in a short period of time and with minimal hassle.

For the most part, you're only typing stuff like this:

\section{A Section}

A call to {\tt open()} will {\bf return} an integer, which represents a {\emph file descriptor}.\cite{man-open}

Easy mode, plus bibtex is a godsend when you have more than a handful of references.


Latex is something that is nice to know, but developers have little need to what it offers.

Latex is required knowledge if you need to create highly structured documents with fine tuned positioning of equations, such as dissertations, math/engineering books, etc.

It is also very useful, but hard to use, if you want to typeset general books, music, etc.

For the needs of software documentation, I think XML is a better fit, because you can convert it as needed to other formats, including Latex.


Related: The (La)TeX Stack Exchange site just opened up to public beta:

http://tex.stackexchange.com/


Sadly, some publishers actually expect Word documents. The same publishers then have all kinds of problems where they need considerable help from the authors to get the layout right.


Including, embarassingly, the magazine of SIGCSE (the ACM SIG for CS education). I was going to submit something a year or two ago, couldn't find the LaTeX stylesheet, and sent an email to the editor---who breezily responded that Word was required, and that their authors didn't really complain about this. Self-fulfilling: I decided it was more trouble than it was worth and published it elsewhere, so although I have complained, I'm not one of their authors!

It does explain why the typesetting is so bad, though. Figures are especially atrocious, and there are pixellation issues and routine font problems throughout.


I was shocked when IEEE Computer wanted a Word document. In their defense, I don't think they actually lay everything out in Word. I think they just decided that's the easiest way for their layout people to get text and figures for an article.


For a gentle start, it's worth looking at LyX -- http://www.lyx.org/ -- a structured document processor that generates LaTeX output. Available for *IX/Mac/Windows, with more features than you can shake a stick at -- and it's open source, so you can try it for free.


This is a good place to put the best explanation I've yet found for how Latex's figure placement algorithm works: http://people.cs.uu.nl/piet/floats/node1.html


FWIW, Word's text layout engine is as sophisticated as LaTeX. IMO, there's just a large layer of other "stuff" that ends up on top of it that usually results in your typical looking Word document.

It's better in Word 2007/2010, but still doesn't seem to be all the way there.


The claim that the Word layout engine is as good as TeX's is not correct.

Even for math-free text, TeX does a better job of hyphenating and line-breaking. The TeX algorithm specifically tries have low variability in line-to-line fill density. Word does not care, which can result in a loose line between two tight lines, causing horizontal stripes in a block of text.

For much more, including ligatures, kerning, and transparency, see:

http://nitens.org/taraborelli/latex

My point above is his point #7.


Ligatures, kerning, hyphenation, etc. can be enabled in Word: http://jeffhuang.com/better_word_papers.html

It's just not on by default which is a shame.


Has anyone done a comparison on how well the kerning/hyphenation/etc. compare to TeX's? As I understand it, even some commercial packages that are designed for this sort of thing still fail to match TeX's. I could be wrong there, however.


Also, the component that powers Word's text layout also does it for IE7/IE8/IE9, WPF and Silverlight (and maybe more, I don't know).

I've heard that Word doesn't play as well with the text layout component as the component authors would prefer. It's possible that this will improve in the future.

As for TeX vs Word, that's a great question. I know that the authors of Word's text layout engine are familiar with Knuth's dead-tree works on typography, but beyond that, I don't know.


It would be great if someone out there did a blind test of Word vs LaTeX layout. It doesn't seem like it would be that difficult -- just get a few pages of text from Gutenberg and render it in both Word and LaTeX.


> Once I create a LaTeX document I can easily convert it to any format I am interested in, including XHTML and Microsoft Word Document.

Am I the only one who finds it impossible to convert a LaTeX document into a Word document without it looking like total crap? What am I missing? I build my resume with LaTeX, and have tried multiple times to get a proper Word document for all those idiots that don't like PDFs, and every time it looks like such crap that I break down and send them a plain text version instead...


Depending on your definition of "total crap", you might find LaTeX2rtf gives you acceptable output with minimal manual tweaking. It works for me, though I'm far from a type snob.


Maybe it's just my specific case, or that my layout is too complicated, but when I try using that, I get errors on the command line, and the output RTF is "total crap" by just about anybody's standards. It has excessive vertical whitespace, including bullets that aren't even on the same line as the text, doesn't have any correct fonts, and doesn't get horizontal spacing right either...

    jreese@mach ~/.../resume » latex2rtf -o JohnReese.rtf JohnReese.tex
    JohnReese.tex:4   Package/option 'oneside' unknown.
    JohnReese.tex:89  Unknown command '\fontfamily'
    JohnReese.tex:90  Unknown command '\selectfont'
    ...
Source: http://files.leetcode.net/resume/JohnReese.tex

PDF: http://files.leetcode.net/resume/JohnReese.pdf

RTF: http://files.leetcode.net/resume/JohnReese.rtf

If you can tell me how to fix that (I know squat about LaTeX and it's associated toolchain), I'll buy you a beer/coffee/cupcake.


On a Mac, the MacTex suite simplifies things pretty well [1]. I typically write my documents in Vim, and then render them to PDFs with TeXShop. It installs all of the standard TeXLive stuff, so if command-line LaTeX is where you're comfortable, that works too.

[1] http://www.tug.org/mactex/2009/


Technology changes all the time but there are a few arguments that never seem to die... WYSIWIG vs. doc prep languages like TeX (or Scribe, remember that?) was a hot topic even back in the 80's, with similar arguments being made. Everything old is new again.

It's amazing to see people getting enthused (again!) about LaTeX.



This article had remarkably little content or analysis. Essentially the only point made was that LaTeX markup can separate content from presentation.


If you use vim then look at the vim-latex suite http://vim-latex.sourceforge.net/


Or don't. It's buggy, overly complicated, and barely maintained.


Agreed. I was really surprised with how odd vim-latex felt. In my experience, most of these language-specific vim plugins stay pretty light, enhancing built-in vim behavior to perform in the expected way given a particular language's peculiarities. Instead, it tries to build up this complex system of macros and shortcuts that added a really thick layer on top of actually writing LaTeX (a process that I actually quite enjoy). Maybe it's another one of those things that I have to see in use to appreciate, and I'm sure there's some really useful stuff in there, but it just didn't seem worth it.


Once upon a time I used some vim plugin--and that one sounds familiar--to allow me to compile from within vim and then jump to that paragraph in the dvi viewer. I think I could also click a paragraph in the dvi viewer and jump to that text in vim.


I concur. Now I use the snipmate plugin, which provides a subset of the functionality: http://www.vim.org/scripts/script.php?script_id=2540


Did he just make fun of a PNAS paper?




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

Search: