Misc FAQS

This is a miscellaneous collection that mixes esoteric questions with practical questions that I have personally found useful.

REMARK: We will refer to the document "Tex For the Impatient" as [TFII].

(NOTE: page numbers for [TFII] are given in the printed numbers, but in the pdf document, this appears with a +20 offset. E.g., page 55 in [TFII] is really p.75 of the pdf document)


  1. How to set the editor for debugging tex
  2. What is the ``^^x'' convention, where x is any character?
  3. How do I combine subscripts and superscripts?
  4. Why does setting \textwidth have no effect?
  5. How do you output the symbol "\"?
  6. How do I do command line changes to TeX behavior?
  7. How do I include figures in latex?


  1. Q: How to set the editor for debugging tex

    ANSWER: When latex has an error, it invokes an editor with the offending latex source file, and goes to the offending line. How do you choose this editor and pass this offending line argument? For instance, on unix-like OS with vi like editors, you can do something like this:
    		> setenv TEXEDIT "/usr/ucb/vi +%d %s"
    		
  2. Q: What is the ``^^x'' convention, where x is any character?

    ANSWER: [TFII] (p.55). This is a way to represent control ASCII characters. E.g.,
    "^^M" is the ascii code for RETURN char,
    "^^J" is the ascii code for LINE FEED char,
    "^^I" is the ascii code for HORIZONTAL TAB char.
    Detail Explanation: ASCII codes are divided into "control chars" and "non-control chars". The former are codes 0-31 and 127-255. Since control chars have unpredictable behavior of terminals, the "^^" convention allows us to represent control chars using a sequence of non-control chars. When you type "^^x", you get the corresponding ASCII code which is either ASCII(x)-64 or ASCII(x)+64. The largest acceptable value for ASCII(x) is 127 and so this notation is unambiguous. But it also means that the largest control char code you can get by this means is 127+64=191.
    Puzzle: if ASCII(x)=63, then you get 127, but if ASCII(x)=62, you get the non-control char 126?
    To get around this 191 limitation, there is another convention. If you type "^^xy" where x,y are hexadecimal digits (0-9, a-f) then you get the corresponding ascii code. Note that x,y must be in lower case for a-f (so A-F will not do). Also, this convention takes precedence over the previous single character "^^x" format. That means that if you type "^^0a" it is the ASCII code 10 that you get, not
  3. Q: How do I combine subscripts and superscripts?

    ANSWER: If you type ``$n^\log_8 3$, then tex will complain about missing braces. You need to do either $n^{\log_8 3}$ (most likely) or $n^\log_{8} 3$ (unlikely).
  4. Q: Why does setting \textwidth have no effect?

    ANSWER: Typically, you do something like
    	\setlength{\textwidth}{6.5in}
    	\setlength{\textheight}{8.5in}
    	
    This should change the dimension of your paper. Why doesn't it work? First, you must be using the article style (not sure what else). It will not work in book style. Second, this must come BEFORE the \begin{document} command. Actually \textheight could work after the \begin{document} but only for page 2 onwards! So it is best to put it before the \begin{document} in any case.
  5. How do you output the symbol "\"?

    ANSWER: Use $\backslash$. Note that "\\" will NOT do, as this is newline.
  6. How do I include figures in latex?

    ANSWER: If you need to include jpg or other bit-map images, you have 2 choices:
    (1) Convert the images into postscript images, and then include them using \includegraphics{} (from the graphicx package). There is a free "jpeg2ps.exe" utility from the web:
    		% jpeg2ps pic.jpg > pic.jpg
    	

    (2) If you do not want to convert them that you must produce a pdf output from your latex source.
  7. How do I do command line changes to TeX behavior?

    ANSWER: There are probably many solutions. I like to use Makefile for everything. Here is a solution based on Makefiles. The idea is for Makefile to create on-the-fly a file (call it "version.tex") with the necessary options. E.g., suppose you have two versions of a file "foo.tex". Assume foo.tex produces two versions of foo, depending on the following macro: \newcommand{\version}[2]{ } % none \renewcommand{\version}[2]{ #1 } % version 1 \renewcommand{\version}[2]{ #2 } % version 2 Put the following commands into your Makefile:
    	
    ############################################################ # VARIABLES ############################################################ OS=cyg OS=unix ver=1 ver=2 ############################################################ # TARGETS ############################################################ ##### We always update the version.tex file first: foo: v latex foo ##### This creates the version.tex v: ifeq ($(OS),unix) echo "\\\\renewcommand{\\\\version}[2]{#$(vnumber)}" > version.tex else echo "\\renewcommand{\\version}[2]{#$(vnumber)}" > version.tex endif
    With this Makefile, you can type "make foo" and it will produce version determined by the variable "ver". But you can determine the version in the command line: e.g. "make ver=1 foo" will create version 1. REMARK: there is a little OS dependent stuff above. Apparently, unix and cygwin echos "\" in different ways, so we need to echo "\" in two different ways.


COMMENTS? yap (at) cs (dot) nyu (dot) edu.