Publishing
Writing papers can be made a real challenge when you have to fight with the software that help create them, especially when publishers require strange formats. Some of the bits below might help make things a little easier.
Setting PDF Metadata
Setting the metadata held in a PDF (author, title, subject etc..) is a nice extra touch. Here's one way of doing it.
If you want to start with what metadata is already present, you can use the line below to extract it to a file. If you want to start from scratch, then just skip this stage.
> pdftk myDocument.pdf data_dump output metadata
Now edit (or create) the metadata file to reflect what you want to change/set. Here is an example of a file.
InfoKey: Author InfoValue: Your Name InfoKey: Title InfoValue: An Interesting Document Title InfoKey: Subject InfoValue: An equally interesting subject InfoKey: Keywords InfoValue: Stuff InfoKey: Producer InfoValue: Hand Crafted
Finally you need to merge your changes with your document. pdftk
will only update the metadata held in
your PDF with those mentioned in your metadata file. It leaves everything else untouched.
> pdftk myDocument.pdf update_info metadata output newDocument.pdf
Make pdflatex
embed fonts
A few publishers require that all fonts are embedded in submitted
publications. If you are using pdflatex
, this is not the default. Fonts can be
embedded quite simply by following the instructions below.
As root, run the updmap
command.
> updmap --edit
Search for the following section in the file and change the pdftexDownloadBase14
option to true.
# # pdftexDownloadBase14 # # Should pdftex download the base 14 pdf fonts? Since some configurations # (ps / pdf tools / printers) use bad default fonts, it is safer to download # the fonts. The pdf files will get bigger, though. # Valid settings are true (download the fonts) or false (don't download # the fonts). #pdftexDownloadBase14 false pdftexDownloadBase14 true
Now rerun pdflatex
on your document and check using pdffonts
that the fonts are embedded.
> pdflatex myDoc.tex > pdffonts myDoc.pdf
name type emb sub uni object ID ------------------------------------ ------------ --- --- --- --------- ESWGSD+NimbusRomNo9L-Regu Type 1 yes yes no 6 0 ICDSLR+NimbusRomNo9L-MediItal Type 1 yes yes no 9 0 BOEROE+NimbusRomNo9L-Medi Type 1 yes yes no 12 0 EMCVFH+NimbusRomNo9L-ReguItal Type 1 yes yes no 15 0 IUDZBA+CMSY7 Type 1 yes yes no 25 0 JWTDPY+NimbusMonL-Regu Type 1 yes yes no 38 0 LSARCX+CMBX8 Type 1 yes yes no 48 0 GZPYGD+CMBX6 Type 1 yes yes no 51 0 FQUPLQ+CMR8 Type 1 yes yes no 54 0 HPHQEW+CMMI8 Type 1 yes yes no 57 0 GNNWKT+CMSY8 Type 1 yes yes no 60 0 OSWSHQ+CMSY6 Type 1 yes yes no 82 0
Paper Size During PS to PDF Conversion
Converting PS to PDF is very easy with the ps2pdf
utility, but it doesn't always seem to respect the
paper size of the original postscript file. This can be rectified with the command format below.
> ps2pdf -sPAPERSIZE=a4 doc.ps doc.pdf
Stopping dvips
Outputting Direct to Printer
When using dvips
to convert your DVI into a postscript file, you can find
your document suddenly being printed rather than going to a file. The reason is
a configuration option in the dvips
config file. Below is a snippet from the
config.ps
that will cause dvips
to output the postscript to a file
rather than sending it to lpr
.
You just need to comment out the option that pipes o to lpr
.
/usr/share/texmf/dvips/config/config.ps
% How to print, maybe with lp instead lpr, etc. If commented-out, output % will go into a file by default. % o |lpr
Joining separate PDF files into a single 'Book'
There are a number of books available online for free. However, it's quite
normal that the different book sections can only be downloaded separately. It
makes life easier when printing and storing the book files if they can be
joined in a single file. The method below uses pdflatex
to do this. There are
other ways, such as pdftk
(described below), but this method is quite flexible.
The important part is the use of the pdfpages
package, this allows
you to include the PDF files. By also making use of the graphicx
package it is possible to scale the included PDFs.
book.tex
\documentclass[10pt]{article} % Set Page Size \usepackage[a4paper]{geometry} % Support for PDF inclusion \usepackage[final]{pdfpages} % Support for PDF scaling \usepackage{graphicx} \begin{document} % Globals: include all pages, don't auto scale \includepdfset{pages=-,noautoscale} % Include the PDF files, scaling as required \includepdf[scale=1.25]{title.pdf} \includepdf[scale=1.25]{toc.pdf} \includepdf[scale=1.25]{ch01.pdf} \includepdf[scale=1.25]{ch02.pdf} \includepdf[scale=1.25]{ch03.pdf} \includepdf[scale=1.25]{ch04.pdf} \includepdf[scale=1.25]{index.pdf} \end{document}
After creating the tex
file, use pdflatex
to create the final single
PDF.
> pdflatex book.tex
Using pdftk
An alternate approach is using the pdftk
tool. The command below give an example of
combining multiple PDFs into a single file.
> pdftk *.pdf cat output combined.pdf
It is a very flexible tool and does much more than this. The
pdftk
web site is well worth a look.
LaTeX
Duplicate Labels Checker
LaTeX
can be a little less than helpful when things go wrong. One such
situation is when you have duplicate labels. The following command will search
your .tex
file for duplicated labels.
> grep -noE '\\label{.+}' document.tex | sed 's/:/ /' | uniq -D -f 1
It works as follows: grep is used to search for occurrences of
\label{}. The -n flag turns on line number output. The output is piped
through sed
to convert the colon separator used by grep into a space. Finally,
uniq
searches for matching labels. The -f 1 flag makes uniq
perform the unique
test on the label field rather than the line number.