# CMYK Output for Printing Prepress

This is the 6th and real last post in the bookdesign series. Previous posts in this series:

Happy Chinese New Year! Well traditionally CNY is celebrated up till the 15th day, so this isn’t a belated greeting. 😉

I thought my post on the front and back covers (+ISBN bar codes) was the last thing I wanted to document in the bookdesign series, but I just realised that I’d still yet to talk about producing a CMYK version if your printer is using a offset-printing process.

You can read about the CMYK colour model and how it it’s different from RGB. In a nutshell, RGB is for on-screen viewing and is more vibrant, CMYK is for commercial printing and seems more “dull”. Check with your printing service if they’re using (on-demand) laser printing or offset-printing to print your material; it may depend on the type of printing stock (i.e. the paper) you choose.

If laser printing is used, RGB is fine, and you can hand over your pdflatex-generated file over as it is. However if offset-printing is to be used, you’ll need to produce your PDF in CMYK colour model instead. Your printing service might be willing to do the conversion for you at their end; but I think it’s more efficient to do this yourself as you’ll have more control over the final PDF. It’ll also give you a more accurate idea of how your design will look in print, so you’ll have a chance of selecting your colours.

### Convert all graphics files to CMYK

Any graphic files that you include (via \includegraphics, for example) must be converted to CMYK. If you have imagemagick, the quick way is

convert image_RGB.jpg -colorspace CMYK image_CMYK.jpg

But I’ve been told that the resulting PDF, when loaded into other applications e.g. Illustrator, contains the “wrong” colours. For more accurate results, you’ll need to use colour profiles as discussed here.

### Invoke xcolor CMYK mode

By default, the xcolor package uses the RGB colour model. To invoke CMYK mode:

\usepackage[cmyk, …other options…]{xcolor}

And then there’s the issue of different kinds of black. If your design contains large areas of black, and particularly if it involves light-coloured text (e.g. white) on a black background, the RGB black directly converted to CMYK would have values of C: 100% M: 100% Y: 100% K: 100% (over-saturated rich black). You then run high risks of getting unwanted “shadows” if the four colours print out of registration, as shown in the sample on the right from this excellent article:

Now the cmyk mode of the xcolor package automatically redefines the colour black to C: 0% M: 0% Y: 0% K: 100%, i.e. flat or standard black. Flat black can look rather “washed-out”, so you might want to define a different shade of black, especially for large areas of black. Check with your printing service for further advice. E.g. our printer recommended to use a “cool black”  C: 30% M: 0% Y: 0% K: 100% for the covers of our Grid Computing Cluster book. Unfortunately I couldn’t figure out how to do it previously, but now I do:

\usepackage[cmyk, …other options…]{xcolor}

%% cmyk values have range [0,1]
\definecolor{CoolBlack}{cmyk}{.3,0,0,1}

%% In case you want to redefine the basic black
%% (0,0,0,1) across the board. Check with your
%% printer if this is advisable!!

\definecolor{black}{cmyk}{.4,.3,.3,1}

%% Force the new black into effect, because
%% xcolor issues \color{black} with the old
%% black before all its initialisations.

\color{black}

In other words, you should always liaise with your printing service concerning the technical specs. You’ll thank them for their expert advice, and you’ll learn a lot about graphics design and the printing process as well.

OK that’s it! That’s truly the last of the bookdesign series. I hope you’ve enjoyed it as much as I did.

# Using Colours in LaTeX

A brief departure from the bookdesign series, as some of my future posts within and outside the series will be dealing with the use of colours, so I might as well get it out of the way first. Summarily, we’ll take a look at how to use colours in LaTeX with the xcolor package. This will work with all outputs, i.e. .dvi, .ps and .pdf.

The most useful commands for applying colours made available by xcolor are:

• \color{color} (applies color to the text in the currrent group)
• \textcolor{color}{text} (applies color to the specified text only)
• \pagecolor{color} (colors the entire page to be color)
• \colorbox{color}{text} (creates a box containing the specified text, with color as the background)
• \fcolorbox{frame color}{bg color}{text} (same as above, but with a coloured border around the box)

See Section 2.6 of the xcolor manual for full list and more details of commands for colour application. Alternatively, if you’re using emacs, you can look it up with

The xcolor package has quite a collection of pre-defined colours; they are listed in Section 4 Colors by Name in the manual. Apart from the 19 “base” colours that are always available, you can also access more pre-defined colours via the dvipsnames, svgnames and x11names options. Here’s a quick example:

\documentclass[a6paper,12pt]{article}
\usepackage[x11names]{xcolor}

\begin{document}

% ‘LemonChiffon1’ from x11names
\pagecolor{LemonChiffon1}

% ‘magenta’ is a base colour
\textcolor{magenta}{Hello World!}

% are available via x11names
\fcolorbox{Firebrick2}{Goldenrod1}{world}.
\end{document}

You can mix up your own colours, too. \color{LemonChiffon1!80} means 80% LemonChiffon1 and 20% white, while \color{lime!30!yellow!60!Mahogany} would be 30% lime, 60% yellow, and 10% Mahogany. You can also give names to the colours you concoct, so that you can reuse them at various points in your document. For example:

• \definecolor[named]{CoolBlack}{cmyk}{.3,0,0,1} defines the CMYK ‘Cool Black’ (useful if your printer asks for CMYK black instead of ‘rich black’)
• \definecolor[named]{AquaBlue2}{rgb}{.553,.769,.98} defines ‘AquaBlue2’ with decimal RGB values (range [0,1])
• \definecolor[named]{Hazelnut}{HTML}{BDA59B} defines ‘Hazelnut’ with HTML RGB values. Useful if you’re re-using colour definitions from CSS styesheets.

If you’re like me i.e. you just can’t hit the right figures to get a colour just right, head over to COLOURlovers for lotsa inspirations and colour schemes. I got almost all my colours for the Grid Computing Cluster report from this website.

Have fun and happy LaTeXing!

# Background images

I’m sure every LaTeX user tried this code at least once to add a “background image” on a page:

\includegraphics[width=\pagewidth,height=\textwidth]{wallpaper_filename}

But the included graphics, even though it looks the right size, would refuse to budge beyond the page margins, leaving a white border all round it. And you’d probably have problem placing any text at all on the graphics, thus defeating the purpose of a “background” image.

The wallpaper package offers an easy way to add background images or wallpapers in LaTeX, including tiling. The following commands are available:

• \CenterWallPaper{}{} where is a value between 0 and 1, for specifying the fraction of paper width or height. The aspect ratio of the graphics will not be changed, i.e. you won’t get a “stretched” wallpaper as you would with your desktop wallpapers.
• \ULCornerWallPaper{}{}
• \LLCornerWallPaper{}{}
• \URCornerWallPaper{}{}
• \LRCornerWallPaper{}{}
The above four commands take the same arguments as \CenterWallPaper, but puts the image at the Upper Left, Lower Left, Upper Right and Lower Right corners of the page respectively.

For tiling wallpapers, there are:

• \TileWallPaper{}{}{}, where you can specify (in pt, cm, in…) the width and height of the included image.
• \TileSquareWallPaper{}{}, where the included image would be re-shaped as a square, and is the number of “image tiles” that will fill up the width of the paper.

Note that all the commands above will apply the background images on every page after the command is issued. To clear the wallpaper, use \ClearWallPaper.

Also, for each command \XXXWallPaper command above, there is a \ThisXXXWallPaper command that takes the same arguments but would apply the background image on only the current page.

You can now run wild with your imagination to design letterheads, chapter headings, covers, etc. Have fun!

# Drawing diagram; the cryptic way

Well, this is not-so-latex stuffs, but I just want to share with you guys…

I managed to tried out 3 applications:

Let’s see for Tikz;

%modified from texample.net
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{mindmap,trees}
\usepackage{verbatim}

\begin{document}
\pagestyle{empty}

\begin{tikzpicture}
\path[mindmap,concept color=red!50!black,text=white]
node[concept] {Hidup}
[clockwise from=0]
child[concept color=green!60!blue]
{
node[concept] {Pertimbangan}
[clockwise from=90]
child { node[concept] {cari duit} }
child { node[concept] {buat amal ibadat} }
child { node[concept] {belajar sungguh-sungguh} }
child { node[concept] {bina keluarga bahagia} }
}
child[concept color=orange] {
node[concept] {research}
[clockwise from=-30]
child { node[concept] {jurnal} }
child { node[concept] {artikel} }
};
\end{tikzpicture}\end{document}

will produce

Raw source snapshot:

will produce:

and finally graphviz;

Source, the “dot” file:

digraph process{
node [color=blue,fontcolor=black,font=helvetica,]
nodesep=1.5
A[label=”Machine Object (MO)”]
B[label=”Portable Object (PO)”]

C[label=”developer”]
D[label=”translator”]
E[label=”tools”]
F[label=”POedit”]
G[label=”kbabel”]

C->B[label=”prepares PO”,style=dashed]
C->A[label=”compiles MO”,style=dashed]
C->B->D [label=”send PO files/i18n”,fontcolor=red]
D->B->C[label=”return translated files/l10n”,fontcolor=green ]
D->E[label=”translate using”,fontcolor=blue,style=dashed]
E->F
E->G
}

returns;

# Using .eps Graphics Files with PDF output

Oops — I forgot to thank the blog owner najmi for inviting me to be an author! How unbecoming of me! *grovel* Thanks again!

For quite some time now, the graphicx package would automatically sort out which file types to use whenever it encounters \includegraphics{some_file}, where the extension of some_file is not specified.

That is to say, if you are generating to a .dvi, the system would look for some_file.eps. If you are generating to a .pdf, it looks for some_file.{pdf|jpg|png}.

But what if you want a .pdf and you work with .pdf, .jpg and .png graphic files, but suddenly you received a .eps graphics from your collaborator? (This actually happened to a lecturer at my university.)

Well, you could always convert it manually to a .pdf yourself with GhostScript or GIMP, of course. But now the process can be automated if you’re using MikTeX 2.8 or TeXLive 2009, as highlighted by Rob Hyndman.

In MikTeX 2.8, use the epstopdf package together with graphicx, like so:

\documentclass{article}\usepackage{graphicx,epstopdf}\begin{document}\includegraphics[width=\textwidth]{some_file}\end{document}

If all you have is some_file.eps, it will be automatically converted to a some_file-eps-converted-to.pdf during the first time the LaTeX document is compiled and included in the final document output.

If you’re using TeXLive 2009, you don’t even have to load epstopdf explicitly, but I say include it anyway, for portability’s sake.