[ 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:

• Remove first two pages:


$pdftk text.pdf cat 3-10 output out_text.pdf  • Remove pages 2, 3, and 6: $ pdftk text.pdf cat 1 4-5 7-10 output out_text.pdf

• Merge PDF files.


$pdftk 1.pdf 2.pdf 3.pdf 4.pdf cat output file1234.pdf  This command merges four files into a final file file1234.pdf. • Split the pdf file into pages. If you want to create a pdf including only the first page of file jpcA.pdf  pdftk jpcA.pdf cat 1 output jpcA_p1.pdf  In case you want to extract pages 1 to 3, leave out pages 4 and 5, and include the rest of the pages you can execute  pdftk jpcA.pdf cat 1-3 6-end output jpcA_partial.pdf  • If you want to extract all the pages of a pdf document in separate files you can use the burst option. If the file document_A.pdf has 8 pages the command  pdftk document_A.pdf burst output document_A_page_%01d.pdf  creates files document_A_page_1.pdf ... document_A_page_8.pdf. • If you want to include a pdf file amid the pages of another pdf document, e.g. we want to include file document_small.pdf after page 8 of file document_big.pdf and save the final result into a file called document.pdf, we can do this as follows  pdftk A=document_big.pdf B=document_small.pdf cat A1-8 B A9-end output document.pdf  • (To Do) Decrypt input or encrypt output. • (To Do) Generate FDF data stencil from PDF forms. • (To do) Apply a background watermark or a foreground stamp. ## 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

$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


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



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

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

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.


\usepackage[cm]{fullpage}


With A4 papersize another possibility is


\usepackage{a4wide}


## 8.13 Changing footnote symbols in LaTeX

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

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

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

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

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

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

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.
Curro Perez-Bernal mailto:francisco.perez@dfaie.uhu.es