I have never learned how to use Latex properly. Whenever writing a paper, I use hacks to override behavior of the underlying template. What would be an intermediate to advanced book on learning how to use Latex to create style files and how to use it most efficiently? The book would ideally help one to get rid of bad habits when using Latex.

I think this question may be off-topic because it is about LaTeX in a rather general way. This used to be considered as somewhat on-topic early on, but since the existence of TeX - LaTeX is not anymore.
–
quidJan 21 at 14:23

15 Answers
15

Preface: I think most people don't learn LaTeX "properly"; they're happy enough to be able to get their documents to look about right with a relatively small amount of effort. There is nothing wrong with that. Being a good mathematician and being a LaTeX wizard have little to do with each other. That said, I really like obsessing over typesetting.

As far as books, I would recommend is you read The TeXbook. You shouldn't be using raw TeX unless you have a good reason to do so, so you might think this book is useless to a LaTeX user, but remember that LaTeX runs on TeX. I find it extremely helpful to understand how the underlying TeX engine works. Also, Knuth is extremely pleasant and stimulating reading (for a mathematician at least). For LaTeX proper, I think The LaTeX Companion is a pretty standard reference; it's nice to read sections on things you're interested in, but I certainly wouldn't recommend reading it like a novel

More important than reading any book, you should become interested in what happens to your documents. You probably already deal with LaTeX errors to get your documents to compile, but you should also investigate LaTeX warnings. A large chunk of my LaTeX knowledge has been acquired while tracking down and eliminating warnings. The nice thing here is that you often get some insight into why something should be done a particular way. For example, if you hack something together to get the job done, you'll often get a warning from the compiler, and in tracking down that warning, you'll likely learn the right way to do it and what was wrong with your hack. For this part of your LaTeX education, this TeX FAQ is very helpful. In particular, I highly recommend learning about the \show command, which allows you to deconstruct macros and understand how they work.

I've found l2tabu to be a very useful guide to avoiding bad habits. Yes, it's occasionally over-dramatic - one of its sections is entitled "Deadly Sins"! - but it does provide good reasons for all the taboos it lists.

But it does only cover sins of LaTeX coding, and not sins of bad typography. I tend to work on the principle that TeX and LaTeX were designed by people who know much more about typography than I ever will, so there's probably a good reason for the default settings. Thus, if in doubt, leave it alone.

That advice probably applies to the question of whether or not to create style files: unless you're creating a whole load of documents which you want to look identical in style, creating a style file only reduces the portability of your document, since you have to remember to include the extra file when you transfer it, etc., etc..

But, if you are writing style files, or class files (which are rather harder to get right!), Appendix A of the LaTeX Companion is exactly what you need, though if it gets complicated you might want to refer to the TeXbook when you need native TeX commands.

Finally, if you come to make pretty pictures and don't want to have to include EPS files and cart them around with the document, the LaTeX Graphics Companion tells you a million and one ways to get lovely diagrams with just a few lines of code; xy is particularly useful for commutative diagrams, though I mainly use pstricks for basically every kind of diagram anyone ever needs.

I think it was Lamport who that the three most common mistakes in using LaTeX
were:
1. Worrying too much about format, and not enough about content.
2. Worrying too much about format, and not enough about content.
3. Worrying too much about format, and not enough about content.

If you're just starting out, I agree strongly with the recommendation in favour
of Grätzer's "More Math in LaTeX". I have found Grätzer more useful than Kopka and Daley, but a beginner might rank them the other way around. Lamport's book on LaTeX is dated and Knuth's TeXbook does serve as a good example over-indexing a book. Eventually (when you come to write a book or a thesis) you will probably need to refer to the "LaTeX Companion".

For your figures, use tikz and pgf.

If you want to try something different there is ConTeXt, this is built on
plain TeX (for which Seroul's "A Beginner's Book of TEX" provides a good introduction). Since most publishers will insist on a LaTeX input file,
your chances to use ConTeXt might be limited. :-(

Of course it depends what those bad habits are. Sometimes people's bad habits involve trying to do things traditional typesetters or designers would never do - for example, setting very narrow margins. I would recommend reading a bit about the craft of typesetting in the traditional sense and reading about the ideas of traditional style design. The TeXBook is a good source for references.

Sometimes bad habits in LaTeX involve hard-coding things like theorems instead of using environments, for example,
\textbf{Theorem 1} {\it This is my theorem.}

However, it doesn't sound like your bad habits are of this nature. Maybe you should give us some examples of the kind of bad habits you have in mind.

I have found with LaTeX life is much easier if you don't fight the template. The defaults are surprisingly sane, and trying to work around them is a headache. Mind, I've never been a wizard with it. You can do some amazing work once you dig deep enough.

I've learned a lot from G. Grätzer, "Math into LaTeX". The first part is a walkthrough on how to write a document the right way (from start to finish). In the appendices, more advanced techniques are explained (redefining commands). It also features the AMS packages and many more (for instance, fancyhdr).

More like 18+ months. You might check for other MathOverflow questions regarding online resources, as well as one users site (MathOnLine? Andrea Feretti? Apologies in advance for any mistakes.) for other places to publish a link. Gerhard "Email Me About System Design" Paseman, 2011.06.24
–
Gerhard PasemanJun 24 '11 at 22:18

3

Actually, I posted this answer 10 months ago. I just updated the link.
–
Predrag PunosevacJun 24 '11 at 22:31