How does TeX work at the command line? More specifically, after having installed LaTeX, I found that typing tex in the command line opened up an interpreter. However, I have no idea what I can do here! If I type something like \pi, nothing happens! What does this TeX interpreter at the command line do?
- 259,911
- 34
- 706
- 1,036
1 Answers
TeX is designed to read input either from a file or from the command line: indeed, if you have a file that doesn't properly end a TeX run you'll get the prompt wait for more input. When you start TeX at the prompt without giving it a file name, you'll get something like
This is TeX, Version 3.14159265 (TeX Live 2014/W32TeX) (preloaded format=tex)
**
where the two * are important. For this first prompt, TeX will try to look for a file name if you give just 'some text'. As such, it's normally safest to put \relax here (\relax is TeX's do-nothing command, so makes no change to the results).
This is TeX, Version 3.14159265 (TeX Live 2014/W32TeX) (preloaded format=tex)
**\relax
*
Notice that there is only one * now: TeX is no longer looking for a file name. Any input given is now treated in exactly the same way as if it were in a file. As we are talking about running tex, that means we use plain TeX syntax. We might therefore do
*Hello world
* $y = mx + x$.
*\bye
[1]
Output written on texput.dvi (1 page, 296 bytes).
Transcript written on texput.log.
That will produce a .dvi file containing thext text Hello world y = mx + c with the formula in math mode. There will also be a page number as plain adds that automatically. You can then convert the .dvi to PDF format sing dvips/ps2pdf or dvipdfmx. (with no file name given, TeX default to the job name texput.)
As noted in a comment, running pdftex will give direct PDF output but otherwise the same process occurs. LaTeX can be run interactively with latex or pdflatex: the same considerations apply except the pre-defined control sequences are different.
- 259,911
- 34
- 706
- 1,036
texat the command line: which one are you aiming to use? (If that question doesn't make sense to you, take a look at What is the difference between TeX and LaTeX?.) – Joseph Wright Jan 08 '15 at 08:36enterand then your\pishould give an error. Type "x" and hit enter to quit. If you type\relax abc \byeat the**prompt you will get a dvi with "abc" in it. If you start the whole experiment withpdftexyou will get a pdf. If you type simplyabctex will try to find and open the fileabc.tex. – Ulrike Fischer Jan 08 '15 at 09:04\relax'does nothing successfully'. It is a command you can give TeX when it expects to do something but you don't want it to. – cfr Jan 08 '15 at 23:54