27

LaTeX is like a language. In order to write LaTeX code I have to understand the "word" and the "sentences structure". I have searched on wiki, some LaTeX books, but they just give the LaTeX command, not how to write a LaTeX code for some specific purpose or to understand the LaTeX code.

Here is one example:

\renewenvironment{svgraybox}%
       {\fboxsep=12pt\relax
        \begin{shaded}%
        \list{}{\leftmargin=12pt\rightmargin=2\leftmargin\leftmargin=\z@\topsep=\z@\relax}%
        \expandafter\item\parindent=\svparindent
        \hskip-\listparindent}%
       {\endlist\end{shaded}}%
%
\renewenvironment{svtintedbox}%
       {\fboxsep=12pt\relax
        \begin{tinted}%
        \list{}{\leftmargin=12pt\rightmargin=2\leftmargin\leftmargin=\z@\topsep=\z@\relax}%
        \expandafter\item\parindent=\svparindent
        \relax}%
       {\endlist\end{tinted}}%
%
}}
%
\let\SVMonoOpt\@empty

I do not know what is \z@, what is \relax, what is \fboxsep ... and if I want to design my LaTeX file in my own form, I know that I have to understand many other things.

Note that I can write simple LaTeX enviroment in mathematics (like the matrix, align, enviroment) but it does not help me to understand the above code.

So, what could I do? What book should I read? Or what programming language should I learn?

Schweinebacke
  • 26,336
trequartista
  • 1,891

2 Answers2

26

The TeXbook is the best place to learn about the underlying TeX language, although TeX-by-Topic (texdoc texbytopic) in most distributions is a good free alternative. But much of what you show is not directly using TeX primitives but using constructs such as \list defined in the latex format. The LaTeX Companion has detail for that or the free documented sources of LaTeX texdoc source2e has lots of information.

This site of course can also be used. For example

David Carlisle
  • 757,742
17

You can find out what any command does by asking LaTeX itself. Just open up a console window and run latex (or whatever variant you prefer), and then you can issue commands line by line.

For example, to find out what \z@ means, you can use

$ latex
**\makeatletter
*\show\z@

and LaTeX will give you

> \z@=\dimen12.

(The \makeatletter command allows you to use the @ sign in commands.)

If you want to find out what length is stored in \dimen12, you can then use

*\showthe\dimen12

which will give you

> 0.0pt

So the \z@ command is a short hand for a zero length.

The \show command will tell you the definition of any command except a primitive; you can look those up online with a Google search.

ChrisS
  • 13,529
  • Thank ChrisS for your answer. I need to understand the LaTex essentially, systematically, but I still do not know what is \show, \makeatletter,... and there will be many other things. So thank for your answer, but I do not think that is a good idea for my case :) – trequartista Nov 12 '13 at 08:47
  • 3
    This is a valid solution when you know a command and you wanna check what it does. But what about the contrary? What if you want to do something and I need to know the command? Please note that this is no attack, I really like your answer (Infact I voted it up). But as a beginner latex enthusiast I exactly understand what the questioner is talking about! I think the question is not about a specific command but a general approach. – Pouya Nov 12 '13 at 09:07
  • @Pouya you really need a book "latex by topic" (by analogy with "tex by topic"). sadly, there is no such thing; and "just now", with the work on a new latex (latex 3) underway, is probably not the time to start. for myself, i learned latex by reading sources (originally latex2.09, back in the 90s) and have learned more as latex has evolved. – wasteofspace Nov 12 '13 at 11:42