# TeX within a LaTeX document?

I'm new to LaTeX and I guess I'm still a little confused about the difference between TeX and LaTeX. Under what circumstances would you actually need to define new TeX macros within a LaTeX document? What's the difference between \def and \newcommand (other than the fact that one is TeX and the other is LaTeX)? Can someone give me an example?

-
Perhaps take a look at tex.stackexchange.com/questions/6776/what-are-tex-and-latex –  Joseph Wright Sep 4 '11 at 14:37
Thanks for the link! –  Alex Lockwood Aug 8 '12 at 20:34

LaTeX is based on TeX, see:

You can use TeX within LaTeX documents, however it's recommended to use LaTeX if possible because

• LaTeX is a higher abstraction level
• LaTeX does more error checks
• Using LaTeX commands in LaTeX commands is simply more consistent, because TeX command don't have to know the LaTeX context they are used within, while LaTeX commands may do

Here's a helpful list regarding LaTeX commands vs. TeX commands:


There's a lot of LaTeX documentation explaining \newcommand and examples. However, you can find a lot of examples using this site's search feature, such as

-

The difference between TeX is not analogous to the difference between, say, C and C++, where it is actually an issue to directly include C code in a C++ program. It's more like the difference between a simple HTML text box like the one I'm using and a fancy text editor like Emacs. (I admit that the analogy between a typesetting engine and a text editor is not that inspired.) Sure, you can use an Emacs window as a text box, but it has a ton of features that make entering and editing text faster and easier, and an infinite capacity to extend them. Of course, in the middle of your hyper-adept Meta-Super-whatever editing session you choose just to type a few lines, it will not break the program. It may even be faster or easier.


Like with Emacs versus text boxes, most of the time you are doing things that don't depend on TeX vs LaTeX at all: entering plain text is the same in both. Also, I have lied in that it is possible for some TeX commands (even primitive commands like \def, or in practice, \atop) to be redefined to give errors in LaTeX. Also note that I am not going to tell you what commands are actually in TeX (as compared to LaTeX) since LaTeX is designed in such a way that you shouldn't even need to know.

I should say that I have never used Emacs.

-