/ Markus Amersdorfer:home / university / about:me /
\ Say NO to Software-Patents! \

TeX & Co

Table of Contents


LaTeX is a document preparation system for high-quality typesetting. The idea is get rid of thinking about the appearance of what you write and concentrate on the content. Besides many other great features, LaTeX offers perfect typesetting of mathematical formulae. Furthermore, it is easily possible to use different output formats such as Postscript, PDF or HTML.

Overfull HBOXes

One of the few "problems" in LaTeX that I know of are the "Overfull HBOXes" -- and they aren't a 'bug' but a 'feature', actually. :)
An "overfull hbox" occurs if LaTeX can not insert a newline or use hyphenation properly. With LaTeX, by default, not being allowed to stretch a line above a certain limit, it rather writes beyond the right edge of the line instead of putting the (whole or part of the) word into the next line. LaTeX views a line as a "horizontal box", and in case it has too much data to put into this box, it is "overfull".

In many cases, an overfull hbox can be ignored, as the human eye won't see the "error" being too small to be recognised. However, in other cases, the output simply looks ugly (at least).

Finding Overfull HBOXes

Inserting \overfullrule=5pt in the preamble results in black rectangulars at the right hand side of the lines where an overfull hbox occurs. This way, you can easily track them down.

Getting rid of Overfull HBOXes


LyX is the first WYSIWYM (= what you see is what you mean) document processor. Using LaTeX in the background, LyX inherits all of LaTeX's advantages. While LaTeX is IMHO somewhat hard to learn, LyX smoothes these rough edges and makes creation of both small and large documents a breeze - it's a really easy to use graphical frontend for the creation of terrific output!

Installing LyX

With the QT libraries compiled and installed under /usr/local/qt/, I compile and install LyX with the QT interface as follows:

Compile and install LyX:
  ./configure --prefix=/opt/lyx --with-frontend=qt --with-qt-includes=/usr/local/qt/include/
  make install

If the configuration process does not find the correct QT libraries, you might have to run the following first (which is only necessary when QT has been compiled manually, usually):

Possibly necessary beforehand:


Though being from Austria, I like to have my programs "talk English" (while, of course, they shall still be able to process European stuff such as German umlauts etc.) - see my Debian documentation for general details on this topic.
With the current GDM2 version in Sarge, I couldn't figure out how to get the desired behaviour, so I'm using XDM at the moment (with this setup using the settings in /etc/environment).

Despite of this, I still had problems with LyX not only talking English but also understanding English in the way that I want to use the English keyboard shortcuts: "ALT+p, i" for "Itemize" (instead of the German "ALT+a, i", with "p" probably meaning "paragraph" and "a" meaning "Absatz").
In order for this to be fixed, I use the following mini-script to start LyX:

  export LANG=C
  /opt/lyx/bin/lyx $@

Document Settings (based on my thesis document)

I wrote my thesis document in LyX. Here are the custom settings:

LyX Keyboard Shortcuts

Besides many others, there are the following ones I use most:

ALT+p, iItemize
ALT+p, dDescription
ALT+p, eEnumerate
ALT+p, sStandard
ALT+p, [123456]chapter, section, subsection, [...], subparagraph
CTRL+SHIFT+pSwitch between typewriter and standard font
CTRL+eSwitch between emphasised and standard font face
CTRL+bSwitch between bold and standard font face
CTRL+mMath mode
CTRL+ALT+[123]Save Bookmark [123]
CTRL+[123]Go to Bookmark [123]
CTRL+tView (as) Postscript
CTRL+gGo to Error (useful if the latex-process returns errors, which show up in LyX)
SHIFT+ALT+RightIncrease environment depth (of e.g. itemizations)
SHIFT+ALT+LeftDecrease environment depth (of e.g. itemizations)

xfig: xfig figures in LyX

Though being a somewhat elder program already and having a user interface one has to get used to, xfig has many features that make it great to be used: With the use of the keyboard-shortcuts, work can be performed quite quickly, etc. But most importantly, xfig figures can be perfectly integrated into LyX / LaTeX, with features such as some text of the figures (e.g. mathematical formulae) being rendered by LaTeX, using the same font as for the rest of the document.
"The LyX User's Guide" (LyX: Help -- User's Guide) explains, how this can be done correctly (simply search for "xfig" in the document). Anyway, here's how I did it ...

xfig: Create the figures correctly in the first place

While the graphical part of the figure is best exported as Postscript (which offers both perfect quality and lots of fine-tuning such as thickness of lines, etc.), the text itself is exported as LaTeX code. This makes it possible for LaTeX to render the text, including formulae etc.

The text to be rendered by LaTeX must have the special flag set: In the "EDIT" dialog of a text, set "Special Flag" to "Special" (instead of "Normal"). The possibly better way is to start xfig with the command "xfig -specialtext", to have any text entered default to the special flag being set.
Save your figure. :)

xfig: Export the figures correctly next

Next, export your figure as "Combined PS/LaTeX (both parts)". This will create two files: A .pstex part that holds the Postscript graphics and a .pstex_t part with the LaTeX commands. (The latter will be included by your document.)
In the "pstex_t" file you will find an \includegraphics{x-y-z.pstex} line in order for the Postscript part to be included too, eventually. Whether the path to the "pstex" file is absolute or relative here, depends on how you created and exported the figure. If you have your .lyx in (say) ~/MyDocs/ and if you use a separate directory for your figures (such as ~/MyDocs/figures/), you should check this path to be either absolute (/home/$USER/MyDocs/figures/x-y-z.pstex), or even better be relative to your LyX-documents-directory (figures/x-y-z.pstex) - with the latter making you somewhat more independent if you refactored your directory structure some day. (If the path was not correct, running LaTeX will throw some errors (which are always "strange" ones in LaTeX, IMHO ;) ...)

xfig: Include the pstex_t file in LyX

The figure is (IMHO) best included in LyX as "Insert -- Floats -- Figure"; give it a name, a label and then include the file in this float: "Insert -- Include File", point to x-y-z.pstex_t and set "Include Type: Input".

xfig: Adapt the preamble of your document

For your file to be compiled correctly by LaTeX, you need to have the preamble include two packages:
(You might be able to get rid of the color-dependency, see lyx-users mailing-list posting if you'd like to.)


The PDF file format offers links inside the document. With the LaTeX package hyperref and the command pdflatex, such files can be created from your LyX/LaTeX documents.
As you can see in my preamble listing above, I'd tried to get them working using the hyperref package, but I did not succeed as either I had hyperref's in the document but pdflatex produced a letter-sized paper, or I had an A4 paper with no hyperref's.

tex2pdf is a Perl-script that manages everything quite perfectly when creating PDF files from your documents.
My best experiences were with the development version 3.2a on an up-to-date (as of February 2004) Debian Sarge machine.

Run "tex2pdf -c" to configure the script according to your wishes. (It is e.g. easily possible to set the color of the hyperref-links this way ...)
To produce a PDF file, simply run "tex2pdf your-doc.lyx" or "tex2pdf your-doc.tex".
(The script manages the conversion of the possibly PS-based figures to PDF-files, which is necessary for "pdflatex", etc...)

Known bugs

As has just been mentioned, "pdflatex" can not process PS-files directly, so they have to be converted to PDF first. Unfortunately, that's a step of the overall process that might mess up your graphics by rotating them by 90°, or something like that. However, this only happened on a rather old Debian Sarge installation (date Aug. 2003 with tetex-1 packages, etc.). The problems disappeared on an up-to-date machine (as of February 2004 with tetex-2.0.2 packages, etc.) and the 3.2a version of "tex2pdf".
(Note: Different conversion programs PS -> PDF have different qualities of output. The "tex2pdf"'s default produces best quality, but sometimes suffers from the rotation bug. You might check out other conversion options (introduced in the current CVS-version of the "tex2pdf" script).)


back to index

Valid HTML 4.01! Valid CSS! Created with Vim [Blue Ribbon Campaign icon]
© Markus Amersdorfer (markus<dott>amersdorfer<att>subnet<dott>at)
last modified: 2010-02-23 15:56:57
22082 hits