Tuesday, October 25, 2011

PIP part 3 - Adjusting the look of your PDF

In the previous post I showed you how easy it is to create a PDF from yWriter5.

I also left you with a cliffhanger: those doubled-up chapter headings. And you're probably wondering how you change the layout when yWriter doesn't seem to have any formatting options. (E.g. paper size, gutters, etc.)

I don't want to throw lots of code at you, so I'll cover the basics in this article and move on to more detail in future.

For now you need to know one thing: where yWriter is concerned you adjust your layout by altering a special text file called a LaTeX header. (You can also override layout on the fly, e.g. in the middle of a scene or chapter, but we'll get to that later.)

In yWriter5, click the Project menu, then Project Settings. This is where you enter the title of your novel, the author's name, and various other novel-specific values like deadline dates. Click the LaTeX tab and you'll see the following:


The Header File textbox is blank, which means yWriter will use the default. This is a file called 'LaTeXDefaultHeader.txt' which yWriter creates in the project folder every time you start a new project.

What you need to do is make a copy of the default header file, then tell yWriter to use the new file instead. Here's how: First, click the Open Project Folder button. Then rename LaTeXDefaultHeader. (I suggest something like LaTeXNameOfProject.txt)

When you've renamed it, click the [...] button and select the new file.

Now click the Edit button to open the header in Notepad. Woah! Nobody told me there'd be codes like these!


That shows my modified Latex file which you can download here. To update yours with mine, open the downloaded file, copy the contents, and paste them into your renamed LaTeX file. Then save your file.

Save the project settings, press Ctrl+Alt+X, open the exported Tex file and press Ctrl+Shift+F5 to generate and view the PDF. It's similar to the one you saw in the previous article, but this time the chapter headings should be correct.


Here's the layout I used for Hal Junior. It's ideal for shorter books with chapter titles. (Instead of 'Chapter 1', 'Chapter 2', etc, I used proper chapter titles like 'The Secret Signal')

In the next article I'll explain how to tweak the codes in the header, and where to find more information on the LaTeX memoir class.

Simon Haynes is the author of the Hal Spacejock Series and Hal Junior: The Secret Signal. By day he's a computer programmer and author, and by night he's the same only sleepier.

Simon Haynes is the author of the Hal Spacejock and Hal Junior series (Amazon / Smashwords / other formats)

14 comments:

Boddaert said...

Beginning to make a little sense now :)
Getting a Code 404 error when I click on your Latex File Link BTW Simon.
Great stuff.

Simon Haynes said...

Thanks - just fixed the links.

Hopefully if I take this instructional series step by step I won't frighten everyone off ;-)

Boddaert said...

Hi, me again. Don't seem to have the 'Open Project Folder' Link on my Latex Tab page, but got around copying and renaming the Latex Header another way.
Sorry to be causing problems. ;)

Simon Haynes said...

That's in the latest yWriter, just uploaded this morning (my time). I realised it needed improving and made a couple of tweaks.

Boddaert said...

Great got the latest features.

Some small problems I'm having Simon, if you can help.

'Save the project settings, press Ctrl+Alt+X, open the exported Tex file and press Ctrl+Shift+F5 to generate and view the PDF.'

These key strokes don't seem to work for me (using Vista Home Premium Service Pack 2), but I can get to the Texworks program by double clicking the Tex file created by yWriter.

Having got the program open the second set of keystrokes don't work so I have to use the programs green arrow button to make the PDF output file (pdfLaTeX+MakeIndex+BibTeX), if this is correct?

All great so far, except that I get no Chapter headings at all, even if I go back and untick the 'supress all chapter titles' in the yWriter Tex page.

By the way, if I'm starting to send you insane, just say so and I'll follow what you're doing in the background for the present.

I'm saving my yWriter files to Drobox and although I've had no problems at all doing that so far, I'm wondering if that might be relevant?

Simon Haynes said...

Don't forget this bit: "Right-click your @TOC chapter and select 'Mark as last chapter of frontmatter'. This is important for page numbering reasons, amongst others. Later on, if you add more front matter after the TOC chapter, make sure you apply this setting again."

Dropbox is NOT recommended with yWriter. It can't keep up with the rate of saving scenes & data. I recommend using yWriter locally then copying your project to dropbox when you exit.

Simon Haynes said...

Ps the Ctrl+Shift+F5 keystroke is in TeXnicCenter, not yWriter. You have to double-click the Tex file after yWriter exports it, but one TeXnic is open it'll just prompt to reload each time you export a new Tex file from yWriter.

Boddaert said...

Hi Simon
See - no matter how simple you make things, some idiot will always miss out the beginning bit!
So far so good, worked like a treat, except for the keyboard shortcuts which I can live without.
Have moved the project back to my hard disk now like a good little student :)
One strange thing I did notice though was that all my speech marks seem to disappear when I export to TEX, whether 'change to single' is ticked or not on the Latex tab. Could this have something to do with me having used 'curly' ones?

Simon Haynes said...

It's supposed to convert them during the process, but if they're coming out blank perhaps it's not working? (I don't use curly quotes, but they occasionally get pasted in when I transfer between yWriter and my word processor.)

Boddaert said...

Changed a few scenes back to straight quotes instead of curly and they export with no trouble.

Boddaert said...

Hi Simon

Is there any way I can change your tex header txt document to fit a page size 9 x 6 easily. Knowing little about Tex I was wondering if there might be a template already out there somewhere that I could use? I tried amending yours but just got into a right bloody mess.
Thanks

Simon Haynes said...

There are two parts to the process: setting the print size, and setting the paper size.

Check the memoir package manual for the official names. (The one you need to change is 'Statement' in the header.)

Once you have the paper size, you can change the print size to match (This is where you define 6x9 instead of 5.5x8)

Boddaert said...

Thanks, I'll give it a try. If the world is suddenly filled with part printed paper, you'll know who it is.

Henry said...

Hi Simon, I can't find the "LaTeXDefaultHeader" file, either by searching via Windows or looking in the project folder.

Have I missed a step?