[ previous ] [ Contents ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] [ 5 ] [ 6 ] [ 7 ] [ 8 ] [ 9 ] [ 10 ] [ 11 ] [ next ]


Some Mini-Howtos of Interest
Chapter 8 - Text Processing and Formatting


Translations of this chapter:

You can find a translation into Ukranian by Kate Belevets of OhMyEssay.com.

You can find a translation to French by Maxwell Edward in this link.

You can find a translation to Hindi by Mahesh Varma in this link.

You can find translations to Sindi and Urdu by Samuel Badree in this link and this link.


8.1 pdftk application examples

Updated on April 18th, 2017.

Updated on December 1st, 2011.

We present several examples of transforming PDF files using the program pdftk, a powerful and simple application to work with PDF files.

  1. Removing pages. If we have a file named text.pdf with ten pages, the following commands transform the file removing certain pages and saving the transformed output in file out_text.pdf:


8.2 Merge two PostScript or PDF files

Updated on December 1st, 2011.

We explain an alternative way to merge PDF files, to avoid using pdftk. This is also applicable to PostScript files.

You can also merge two PostScript or PDF files using gs

      
     $gs -q -dNOPAUSE -dBATCH -sDEVICE=pswrite \
            -sOutputFile=bla.ps -f foo1.ps foo2.ps
      
     $gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite \
            -sOutputFile=bla.pdf -f foo1.pdf foo2.pdf

8.2.1 References

  1. Debian Reference Guide


8.3 Include et al. in bibtex

You can include the term et al. to replace a long set of authors in a bibtex reference using and others. Thus, if you want to include only the first two authors and replace the rest by others, the bibtex author field should be written as

      
     author =    {First Author and Second Author and others},

8.4 Include bibliographical info in each chapter using LaTeX

You can include the bibliography after each chapter in LaTeX using the package chapterbib. You can even change the citation style for each chapter. In order to do so include at the beginning of the main tex source file the line

      
     \usepackage{chapterbib}

Then at the end of each chapter include

      
     \bibliographystyle{alpha}
     \bibliography{texfilename}

For each chapter you can change the bibliography style if necessary. If you are using \include{filename do not forget to run bibtex to each of the included files possessing a bibliography entry.


8.5 Comment paragraphs in LaTeX

In order to comment one or several paragraphs in a LaTeX source file instead of making use of the % character you can use the verbatim package including at the beginning of your tex file

      
     \usepackage{verbatim}

And then you can simply comment several lines of the file making use of \begin{comment} and \end{comment}

      
     \begin{comment}
     Commented fragment ...
     \end{comment}

8.6 Installing appropriately a LaTeX package or style.

The way to install a LaTeX package in the right path is shown. The first step is to look for the place where the package should be installed.

     $ kpsewhich -expand-var "\$TEXMFLOCAL"
     /usr/local/share/texmf

Unpack the latex package that is going to be installed and copy the directories (bibtex/, doc/, tex/ ...) to the previous path, /usr/local/share/texmf and rehash the database.

     $ sudo cp -r doc tex source bibtex  /usr/local/share/texmf
     $ texhash 
     texhash: Updating /usr/local/share/texmf/ls-R... 
     texhash: Updating /var/lib/texmf/ls-R-TEXMFMAIN... 
     texhash: Updating /var/lib/texmf/ls-R-TEXLIVE... 
     texhash: Updating /var/lib/texmf/ls-R... 
     texhash: Done.

The style is now ready and installed.


8.7 Change the selected language in DebianDoc files

In order to change the selected language for a DebianDoc sgml file the option -l is employed. This affects the different tags and labels in the text.

For example, assuming that the default language in the system is English and we want to generate a version in Spanish in ASCII format of the file test.sgml we should employ

      
     debiandoc2text -les_ES test.sgml

In this case we suppose that the locale es_ES is available[14].


8.8 Avoid Page %d may be too complex to print errors.

When preparing pdf files from LaTeX files sometimes the dvipdf script takes a very long time to complete the pdf file and outputs some errors like in the following example.

      
     $ dvipdf test.dvi 
     Page 1 may be too complex to print
     Page 3 may be too complex to print
     Warning:  no %%Page comments generated.

Moreover, when the final pdf file is opened with a viewer there is a long series of error messages

      
     $ xpdf test.pdf 
     Error: Bad bounding box in Type 3 glyph
     Error: Bad bounding box in Type 3 glyph
     Error: Bad bounding box in Type 3 glyph
     Error: Bad bounding box in Type 3 glyph
     Error: Bad bounding box in Type 3 glyph
     Error: Bad bounding box in Type 3 glyph

This is due to the inclusion of the command \usepackage[T1]{fontenc} in the input file. This is convenient when writing in Spanish because in this way you have access to special characters (as accented letter).

The solution to the problem consists in making use of the latin-modern fonts. The heading of the tex file should include

      
     \usepackage[T1]{fontenc}
     \usepackage{lmodern}

The Debian package that includes this fonts should be installed and its name is lmodern.deb.


8.9 Diverse LaTeX lists

LaTeX distinguishes between three different list environments: enumerate, itemize, and description. Each environment provides four levels, which implies you can have nested lists of up to four levels. The description of the three environments is the following.

  1. Enumerate

    The syntax in this case is

         \begin{enumerate}
         \item ...
         \end{enumerate}
    

    The enumerate environment permits the definition of numbered lists. If you like to change the appearance of the enumerator, the simplest way to change is to use the enumerate-package, giving you the possibility to optionally choose an enumerator.

         \usepackage{enumerate}
         ...
         \begin{enumerate}[I]%for capital roman numbers.
         \item
         \end{enumerate}
         
         \begin{enumerate}[(a)]%for small alpha-characters within brackets.
         \item
         \end{enumerate}
    
  1. Itemize

    Itemization is probably the mostly used list in LaTeX. It also provides four levels.

         \begin{itemize}
         \item ...
         \end{itemize}
    

    The bullets marking each item can be changed for each level using the following command:

         \renewcommand{\labelitemi}{$\bullet$}
         \renewcommand{\labelitemii}{$\cdot$}
         \renewcommand{\labelitemiii}{$\diamond$}
         \renewcommand{\labelitemiv}{$\ast$}
    

    Amongst the more commonly used symbols are $\bullet$, $\cdot$, $\diamond$, $-$, $\ast$, and $\circ$.

  1. Description

    The description list is very handy if you need to explain notations or terms. Its neither numbered nor bulleted. The user can define the string marking each item.

         \begin{description}
         \item[] ...
         \end{description}
    

In the three environments the space between different items can be controlled with the \itemsep command that can only be added just after begin

     \begin{itemize}\itemsep2pt
     \item
     \end{itemize}

8.9.1 References

  1. LaTeX Lists Environments


8.10 Use Unicode encoding in LaTeX

In order to use utf encoding in LaTeX the following line should be added to the tex file

      
     \usepackage[utf8]{inputenc}

If this option does not work use utf8x instead utf8.


8.11 Use color in LaTeX

Added on November 30th, 2011.

In order to use colors in your in LaTeX the following line should be added to the file preamble

      
     \usepackage{color}

The text can be colored in different ways

      
     \textcolor{declared-color}{text}
     {black text\color{declared-color} text}

where declared-color is a color that was defined before by \definecolor. You can change the background color of the whole page by:

      
     \pagecolor{declared-color}

8.11.1 References

  1. LaTeX Color in LaTeX Wiki Book


8.12 Easy way of defining smaller margins in LaTeX

Added on January 20th, 2012.

Updated on February 1st, 2012

In order to define a LaTeX document with smaller margins than the default without tampering too much with measures and sizes the fullpage package can be used adding the your document header

      
     \usepackage[options]{fullpage}

Possible options for this package are

  1. in: (default) margins set to 1 in.

  1. cm: margins set to 1.5 cm.

  1. plain: (default) selects plain page style.

  1. empty: neither headers nor footers.

  1. headings: both headers and footers.

  1. myheadings: both headers and footers.

      
     \usepackage[cm]{fullpage}

With A4 papersize another possibility is

      
     \usepackage{a4wide}

8.13 Changing footnote symbols in LaTeX

Added on January 8th, 2016.

The standard footnote symbol in a LaTeX text are numbers, and sometimes, when combined with equations, can produce certain ambiguity. The symbols can be changed to a set of rotating nine different symbols adding to the text preamble

      
     \renewcommand{\thefootnote}{\fnsymbol{footnote}}

Another option is to change to alphabetic uppercase labels with the command

      
     \renewcommand{\thefootnote}{\Alph{footnote}}

8.14 Using the same footnote mark in LaTeX

Added on February 5th, 2012.

Sometimes in LaTeX it is necessary to make reference to the same footnote several times in a page. The following syntax allows for this

      
     Text that has a footnote\footnote{This is the footnote} looks like this. Later text referring to same footnote\footnotemark[\value{footnote}] uses the other command.

It is important to take into account that this doesn't work if there are other footnotes between the first reference and any of the other duplicates.


8.14.1 References

  1. LaTeX wikibooks


8.15 Using the euro symbol in LaTeX

Added on February 7th, 2012.

The euro currency symbol in LaTeX is added making use of the package eurosym, which is part of all the major GNU/Linux distributions. The package has to be loaded in the document header

      
     \usepackage{eurosym}

Then there are two possible ways of including the euro currency symbol.

      
     The book is 10 \euro.
     The book is \euro 10.
     The book is \EUR{10}.
     \textbf{The book is \EUR{10}.}
     \textit{The book is \EUR{10}.}

8.16 Changing pages to landscape orientation in LaTeX texts

Added on November 16th, 2012.

The occurrence of a large table or figure in LaTeX sometimes hamper the display in the default portrait orientation. This can be solved changing one or various pages to landscape orientation.

The geometry package allows to change the full document to landscape orientation adding to the document header

      
     \usepackage[landscape]{geometry}

The lscape package allows to change to landscape orientation a section of the document. To do so add the following line to the document header

      
     \usepackage{lscape}

And whenever it is needed to switch to landscape orientation, e.g. to include a large table or figure the region affected by the change is defined as

      
     \begin{landscape}
     ... table or figure here ...
     \end{landscape}

This is specially suited for printing. To change also the orientation in the pdf file and for better screen readibility use the package pdflscape in the header instead of lscape

      
     \usepackage{pdflscape}

And proceed as before

      
     \begin{landscape}
     ... table or figure here ...
     \end{landscape}

8.16.1 References

  1. Landscape in LaTeX


8.17 Including single column figures or tables in a double column LaTeX document

Added on November 18th, 2012.

Sometimes when writing a two-column document the occurrence of a large table or figure in LaTeX forces its display in a single-column way. This can be solved for figures and tables using the -* variant

      
     
       \begin{table*}
     
       \end{table*}
       \begin{figure*}
     
       \end{figure*}

In this way figures and tables will occupy the full page.


8.18 Controlling horizontal spacing in LaTeX

Added on January 15th, 2016.

The horizontal spacing between words and between words and objects in LaTeX is automatically determined. However we may be interested in adding or removing space. This can be done making use of the command

      
     \hspace{length}

Where length can be expressed in cm, px, etc. If such a space should be kept even if it falls at the end or the start of a line, use the command \hspace*.

The command

      
     \stretch{n}

acts differently, generating "elastic" spacing. It extends until all the remaining space on a line is occupied. If two \hspace{\stretch{n}} commands are issued on the same line, they grow according to the stretch factor.

      
     X\hspace{\stretch{1}}
     X\hspace{\stretch{2}} X
     
     x        x                x

8.18.1 References

  1. Horizontal Space LaTeX WikiBooks


8.19 Including BibTeX References in the TeX source file

Added on July 2nd, 2019.

Once you successfully compile your LaTeX source, including external references with bibtex from a bibfile you can include the references into the LaTeX source following two steps.

First, remove the line in your tex file defining the bibliography, e.g. \bibliography{xxx}, and then insert in the file the contents of the bbl file previously generated. Remove then the existing aux file and recompile.


[ previous ] [ Contents ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] [ 5 ] [ 6 ] [ 7 ] [ 8 ] [ 9 ] [ 10 ] [ 11 ] [ next ]


Some Mini-Howtos of Interest

Curro Perez-Bernal mailto:francisco.perez@dfaie.uhu.es