LaTeX - A document preparation system

mail

Underfull \hbox (badness 10000) in paragraph at lines x--y

Underfull \hbox (badness 10000) in paragraph at lines x--y
[] [] [] [] [] []						this must mean something too, but what ?
mail

Overfull \hbox (11.24971pt too wide) in paragraph at lines x--y

Situation

Compilation of LaTeX documents very often outputs errors such as :
Overfull \hbox (11.24971pt too wide) in paragraph at lines x--y
[]\TU/Lato(0)/m/n/10 Lorem ipsum dolor sit amet, \TU/lmtt/m/n/10 consectetur adipiscin
g elit
These are only warnings (i.e. you may just ignore them), until the day something breaks ...

Details

This is caused by a series of events :

Solution

None of these solutions is perfect : you'll have to reach a trade-off between the time spent to fix / hack and the visual result (hint : the quicker the less efficient )

Specify a different font

You probably have a macro like :
\newcommand{\myBeautifulMacro}[1]	{\texttt{#1}}
which is causing all this trouble. What you'll basically have to do is to turn it into :
\newcommand{\myBeautifulMacro}[1]	{{\fontfamily{lmss}\selectfont #1}}
  • \fontfamily{fontSpec}\selectfont is how you select the fontSpec font
  • the extra surrounding braces {} are there to limit the scope of the font change (i.e. make this an "inline" style, for those who are familiar with CSS). This is a common LaTeX hack.
  • the hard (HARD !) part is to find the fontSpec value (here lmss)

Finding the fontSpec value (source) :

Sorry, this is still pretty mysterious to me. Unsorted notes below...
The LaTeX Font Catalogue :	http://www.tug.dk/FontCatalogue/

https://tex.stackexchange.com/questions/2305/what-fonts-are-installed-on-my-box
	updmap-sys --listmaps | less

'fc-list' : list available fonts
	fc-list | cut -d\ -f2-99 | cut -d: -f1 | sort -u
	fc-query /usr/share/texmf/fonts/opentype/public/lm-math/latinmodern-math.otf


https://tex.stackexchange.com/questions/25249/how-do-i-use-a-particular-font-for-a-small-section-of-text-in-my-document
	find /usr/share/ -type f -a -name "*sty" -exec grep -lE 'renewcommand.*sfdefault' {} \;
	find /usr/share/ -type f -a -name "*sty" | xargs -I truc bash -c 'grep -E "renewcommand.*sfdefault" truc && echo truc' > result.txt

lmtt	Latin Modern Typewriter	==> no error, but I'm actually trying to avoid typewriter fonts
lmr	Latin Modern		==> works but doesn't match with other fonts (serif / sans serif ?)
lmssq				==> fine but too big
lmss


Fonts 3-letter codes : https://www.overleaf.com/learn/latex/Font_typefaces#Reference_guide

https://tex.stackexchange.com/questions/44361/how-to-automatically-hyphenate-within-texttt
mail

How to type special / accented letters in LaTeX ?

  1. save / convert your document.tex as UTF-8
  2. add to the document preamble :
    \usepackage[utf8]{inputenc}
    \usepackage[T1]{fontenc}
  3. enjoy typing characters normally

Alternate solution

Type the special characters :
To display... Type
\ $\backslash$
| $|$
° $^{\circ}$
ç \c c
œ (like in "œuvre") \oe
&, $, #, _, % \&, \$, \#, \_, \%
é \'e
è, à, ù \`e, \`a, \`u
â \^a
ï \"i
mail

LaTeX errors

Here are some common errors I encountered with LaTeX and Beamer, and their solutions :
Package babel Error: Unknown option `frenchb'. Either you misspelled it (babel) or the language definition file frenchb.ldf was not found.
apt-get install texlive-lang-french
LaTeX Error: File `mdframed.sty' not found.
apt-get install etoolbox
File ended while scanning use of \next
2 things to do (source) :
  1. \end{frame} can NOT be indented
  2. \end{frame} cannot have any comments directly after it
mail

pdflatex

pdflatex actually is :

ll /usr/bin/pdflatex
lrwxrwxrwx 1 root root 6 Nov	3 03:50 /usr/bin/pdflatex -> pdftex*

And where does it come from ?

dpkg -S /usr/bin/pdftex
texlive-binaries: /usr/bin/pdftex

mail

LATEX

Setup (source, see also) :

apt-get install texlive-base texlive-lang-french texlive-latex-base

Files of any LATEX report:

  1. While working with LATEX, you will produce a text file document.tex
  2. Then, you have to "compile" it :
    latex document.tex
    This outputs document.dvi (DVI = DeVice Independant)
  3. This .dvi file can be :
    • viewed as is : xdvi document.dvi
    • or converted to PDF : dvipdf document.dvi and viewed with GhostView: gv document.pdf

Tips for fancy headers :

Headers and footers have left and right sides, which content can be explicitly specified :

\fancyhead[Descriptors]{Text}

Descriptors value must be chosen from :

  • L : left
  • C : center
  • R : right
  • E : apply to even pages
  • O : apply to odd pages

examples (source) :

\fancyhead[RO,LE]{\title}
\fancyfoot[C]{- \thepage{} -}

How to generate nice pdf files from LATEX documents ?

When you make pdf files from LATEX with dvipdf or pdflatex, the fonts are very ugly to look at on the screen. This _may be_ because the standard LATEX fonts are not supported by Acrobat reader.
Solutions :

  1. using the times font :
    As a non-LATEX expert, I just want my PDF files to look nice, so let's go for the easy solution: include the times package in the header of the LATEX file : \usepackage{times}
  2. OR : Using fontenc and dvips+ps2pdf, or dvipdfm :
    I don't want the times font, I want to use the standard LATEX font. (Full technical details here !). So the header of my .tex file may look like :
    \usepackage[T1]{fontenc}
    \usepackage{ae}
    When I have made my .dvi file, I write :
    dvips -Ppdf -o outfile.ps myDviFile.dvi
    Afterwards when I make the pdf with :
    ps2pdf outfile.ps
    Everything looks fine.
    Instead of dvips, you can also go directly with dvipdfm (must be downloaded and installed), and specify the resolution and paper format :
    dvipdfm -p a4 -r 600 -o report.pdf myDviFile.dvi
    You can find lots of comments and solutions to he problem if you search Google with e.g: ae package fontenc T1 EC pdf.

How to create an Introduction chapter without numbering ?

Just declare it this way :
\chapter*{chapter_name}

Playing with colors (source, example : colors.tex) :

  1. use the color package with the nodvipsnames option (disables the named model for dvips, to save memory) :
    \usepackage[nodvipsnames]{color}
  2. define your own colors with :
    \definecolor{colorName}{rgb}{rr,gg,bb}
    Other models than rgb are available, such as cmyk
  3. use your colors:
    • \pagecolor{colorName}: to change the page background color.
    • \color{colorName}: toggles the current text color.
    • \normalcolor: switches to the color that was active at the end of the preamble. Thus placing a \color command in the preamble can change the standard color for the whole document.
    • \textcolor{colorName}{Lorem ipsum dolor sit amet}: writes "Lorem ipsum dolor sit amet" in the specified color
    • \colorbox{background_color}{Lorem ipsum dolor sit amet}: writes "Lorem ipsum dolor sit amet" with a background color
    • \fcolorbox{frame_color}{background_color}{Lorem ipsum dolor sit amet}: writes "Lorem ipsum dolor sit amet" with a background and a frame
xdvi can only render monochrome. Transform your document into PDF format to see the colors.

Using hyperlinks in PDF documents

  1. Load the hyperref package with its set of arguments (syntax : \usepackage[options]{packageName}):
    \usepackage[
    pdfauthor={John Doe},
    pdftitle={The title of the document},
    pdfsubject={The subject of the document},
    pdfkeywords={document,keywords,separated,by,coma}
    ]{hyperref}
  2. insert links in your .tex document :
    • To an external target :
      • \href{target}{text}
      • \url{url}
    • To an internal target :
      • Link : \hyperlink{targetName}{text}
      • Target : \hypertarget{targetName}{text}
  3. Notes

    • The font looks better with pdflatex than with dvipdf but images are gone
    • Hyperlinks work just fine while reading the PDF as "embedded" in a browser, but nothing happens if they're opened straight from Acrobat Reader
    • Looks like once hyperref is used, links are automatically created for the table of contents.
    • View example

How to include an external file ?

\input{file}

The \input command causes the indicated file to be read and processed, exactly as if its contents had been inserted in the current file at that point. The file name may be a complete file name with extension or just a first name, in which case the file `file.tex' is used. (???)