PUBLISHING AND LAYOUT
SHORT TUTORIALS ON GETTING THE MOST OUT OF
LYX AND OTHER UNIX LAYOUT PROGRAMS


HOME  AUDIO  CD BURNING  INTERNET  HTML TOOLS  CONTEXTUAL MENUS  UTILITIES 

     

Setting up PDF Services

Creating Multipage PDF files out of tiff images

Introduction to Lyx Word Processor

Configuring Lyx Keyboard Bindings

Troubleshooting LyX


Setting up PDF Services

In OS X.2.4, Apple has added a neat little feature in OS X print dialogues. When you click on the little PDF icon in the window, a menu provides various pdf workflow options, as seen below:


There is, however, a bit of a catch in the feature: you have to configure it entirely on your own, including the workflow options. Getting the icon and menu to appear isn't too difficult. Just Create a folder called "PDF Services" and place it in your Library folder (the one in your home folder). But to have options other than "Save As PDF" will require some doing. You have to add Applescripts, application aliases, or unix shell scripts. We'll do all three to get the menu seen in the picture.

First, the easy ones: "Open in Safari" and "Open in Acrobat Reader." All you need to do is make aliases of your Safari and Acrobat Reader applications icons and place them in the "PDF Services" folder. The "Send PDF via Mail" is from an Applescript compliments of Apple. It can be found
here. The "Convert PDF to text" comes from a shell script I found at macosxhints.com, but which I have freely altered to suit my purposes. In order to work, you must have an installation of ghostscript (via fink). The script is as follows:
#!/bin/tcsh
set outDir = ~/Desktop/
set infile = "$3"
set outfile = "$outDir""$1:t:r".txt
set logfile = "$outDir""$1:t:r".ps2ascii.log
touch "$logfile"
echo "$3"  >>&  "$logfile"
cp -f "$infile" /tmp/ps2ascii-Tmp.pdf   >>&  "$logfile"
ps2ascii /tmp/ps2ascii-Tmp.pdf /tmp/ps2ascii-Tmp.txt  >>& "$logfile"
mv -f /tmp/ps2ascii-Tmp.txt  ~/Desktop/"$1:t:r".txt  >>& "$logfile"
rm -f /tmp/ps2ascii-Tmp.pdf /tmp/ps2ascii-Tmp.txt  >>& "$logfile"
mv "$logfile" ~/.Trash
open "$outfile"
Simply open up the terminal, type in:

pico convert

Paste the above script into the terminal, press control-x, y, and enter, then make the file executable with the following line:

chmod +x convert

Drag the file into your ~/Library/PDF Services directory and rename whatever you like. It should show up in your PDF workflow menu and, if you're lucky, will create a text file, which TextEdit.appwill automatically open, of any document that contains text in it, whether html, word, or PDF.

Creating Multipage PDF files out of tiff images

If you have installed, through fink, ghostscript and tifflib, you will have on your system a number of tools that can be used to convert postscript files to PDF files.  Among them are  ps2pdf, tiff2ps, and tiffcp.

Suppose, then, that we want to make a PDF file out of a collection of tiff files.  This task is easily accomplished as follows.  First, concatenate your tiff files into a single combined tiff file using the tiffcp command:

tiffcp tiff1 tiff2 tiff3 tiff4 tiffcombined.tiff

Tiff files one through four need to be dragged into the terminal.  Make sure you enter a space between them. The "tiffcombined.tiff" file is then typed in by hand.  After you have combined the tiff files into a single file, you convert them to a combined postscript file using tiff2ps:

tiff2ps -ap tiffcombined.tiff > postscriptcombined.ps

Now we simply convert the combined postscript file into PDF format with ps2pdf:

Introduction to LyX word processor

With lyx we move away from a command-line interface and find ourselves back in the more comfortable territory of a GUI program.  LyX, which uses an "industrial strength" typesetting engine, LaTeX, in the background, is a high quality word processor.  It comes with a number of templates and  layouts that make it fairly easy to manufacture specially formatted documents.

Begin by starting lyX.  (LyX is an XWindows program, so you'll need to fire up XDarwin in order to run it.) Go to the file menu and click on new, as shown below:

Now select the <Standard> selector from the toolbar.  A menu will appear giving you a list of formatting options:


Simply select from this list to acquire the type of formatting that you desire.  All these formatting commands work will within each other and provide a great deal of automatic context.  For example, section and subsection formats remember the correct numbers, regardless of where you put them in your document. Experiment a little to see how it works. (LyX also features a whole host of keyboard commands that save the user from having to continuously drag the mouse to the formatting menu. These commands, however, require a bit of configuring before they will work, which we will examine in the next section below.)

In addition to these formatting tools, there are several more in the Insert menu, as we see below:


Again, LyX is very good at figuring out the numbering of inserted items.  It will figure out the correct number of footnote and section and chapter headings automatically — no need to ever worry about it. You can even do cross referencing to page numbering and never have to worry about it referencing the wrong page.

Another very useful feature of LyX is preconfigured templates and layouts.  Go to the file menu and click on <New from Template>, then choose from one of the dozen or so selections.  The letter template looks like this:


Using the template, it becomes very easy to create a document with the required formatting, like the letter above.  Simply fill in the text in the proper places, as in the following example:

LyX is not exactly a WYSIWYG word processor.  To get an idea what this letter will look like when printed out, press control-d>.  Here's what we get:


Once it is exported as a PDF file, you can open it and print it either in Preview or Acrobat  Reader.

Configuring LyX keyboard bindings

To get LyX's keyboard shortcuts working in Apple's X11 or XDarwin, we will need to do a little bit of mucking around in the terminal. We will begin by activating the metakey, which is the key to the whole thing. First, we need to find if there is an .Xmodmap file in your home folder. Fire up the terminal.app and enter:

pico .Xmodmap

If it says "new file" at the bottom of the screen, you don't have a .Xmodmap file. No problem, we've just created one. Enter the following into your new file, which will turn your command key into a metakey under XWindows:

If your .Xmodmap file is not empty, just use control-v to scroll to the bottom of the file, and enter the lines above. This finished, we will next enable option key as a compose key for entering foreign and special characters:

keycode 66 = Mode_switch

Now press control-x, y and return. We're done. All we have to do now is get XDarwin or X11 to enter these changes whenever it starts. This involves a bit of editing of the .xinitrc file. Enter from your home directory:

pico .xinitrc

Using control-v, scroll down through the file until you run across the following line:

# start some nice programs

Keep in mind now, you are in a command line text editor. You cannot use the mouse to position your cursor. Use the arrow keys to position yourself so you can enter the following below the line quoted above:

xmodmap ~/.Xmodmap
Save the file with control-x, y, and return. If you are running X11, you need to make sure your preferences are set right to enable use of the metakey in LyX. Under the "input" tab, make sure that "Follow system keyboard layout" and "Enable key equivalents under X11" are disabled.  Now start (or restart) XWindows. Fire up LyX. Go to the "Layout" menu and select Document, and from the Document Class, select book:


Now we can begin to experiment with keyboard shortcuts. In LyX, many of them work a bit differently then what most of us are accustomed to in normal Mac or Windows programs. Instead of entering just one command (say, command-h to hide application), you press command-p and then one other letter to make good the desired effect. Let's start by entering a title for our book. Press command-p. Note the changes in the status bar at the bottom of the LyX window:

 
It reads "M-p options" — and then lists the letters you can press to issue some kind of command. We'll try S-t, which stands for shift-t. This should bring up the title mode. Enter a title. Next, press command-p followed by shift-a. This is author mode. Enter your name. Next press command-p followed by 1. This will bring up "Chapter 1" in the lyx document. You must enter a title for your chapter to proceed. Then press command-p and 5 to enter paragraph to mode.


This should get you started. Play around to find out what some of the other options do. Try some other commands as well. Command-s gives you options to change font size. Command-m gives you options to enter mathematical expressions.  And, when enabled, command-z provides access to screen and play writing options.  Be warned: you may be need to adjust your LyX bind file to make some of these work.  Open the preferences (under Edit menu) and click on the "Look & Feel" tab and the "Interface" sub-tab.  Click on the browse button to select appropriate file. So, to get the bindings for Broadway document, change the bind file to the broadway bind.

One problem I have repeatedly experienced with LyX is getting certain document layouts to work properly. I use LyX mostly for the broadway and hollywood layouts, yet I often experience trouble with them, largely, I suspect, because they are not always configured to work with the latest LaTex installation, which oftentimes does not include class files for broadway and hollywood. When this happens, either you can't translate or display broadway or hollywood documents as PDF of dvi files, or they won't even work with LyX. How do you fix this? It's not all that difficult, if only you know how.

The trick is to copy the broadway.cls and hollywood.cls files into the /sw/share/texmf/tex/latex/base directory. You can find the class files in /sw/share/latex/tex/ directory. A terminal command like the following should get the job done:

Yet this is not all that has to be done. You also need to run texhash  and a configure script in /sw/share/latex/tex/. You can do it with the following two commands:

Now start LyX and, going to the "Edit" menu, select "reconfigure." Restart LyX and your broadway and hollywood document layouts should work fine.