Friday, May 11, 2012

Multi-chapter document in XeLaTeX

After about six months of writing my dissertation using TexWorks, I've figured out a format and a workflow that seems to be working. (Where "working" means something like "I'm getting consistent writing accomplished and the output is properly and attractively formatted.")


The workflow aspect of writing involves using Scrivener and TexWorks together. I don't rely on the multi-markup function in Scrivener to export to Tex, just because I don't want to deal with fixing the inevitable bugs. Rather, I use Scrivener for free-writing, outlining, and visualizing the structure of my document. I have a very small goal of 500 words a day that I can track using Scrivener's target word count feature. It's easy for me to view an outline, tag pieces of a document, and move things around quickly. I do all this in the "research" section of Scrivener, where I can also pull in PDF files and view them using split-screen.

When it comes to composing actual chapters, though, I write in TexWorks. This is so that I don't have to go through and fix bugs from the way Scrivener might export it for TeX, and so that I'm compiling as I go (to avoid making a mistake early on that impacts the entire document). I copy drafts from Tex to Scrivener into my "dissertation" section, where I also have word counts and goals. I make sure I'm only going in one direction (from Tex to Scrivener) so that I don't inadvertently copy over something I've written.

One goal has been to get the format right ahead of time so I'm not spending a lot of time fixing that before I submit the document. With the template in place, that's pretty well accomplished. Another goal is to maximize writing time so I'm not fiddling with layout and fonts, and etc. That's partly accomplished in virtue of the first goal, but also because neither Scrivener nor TeX give me a lot of superfluous things to "play" with. And I can see exactly how much writing I've done using Scrivener's word target, so I'm not fooling myself.


The dissertation layout itself is taken from the template on the University of Texas at Austin's website. It took me a little while to figure it out, because I thought I needed to copy some files into my file structure, or run "texhash", etc. Instead, I put the "utdiss2.sty" file into the directory where I'm keeping all of my chapters.

Basically, I have a "keatingdiss.tex" file which will call the individual chapters (using \include). While I'm writing, I can use the % symbol to block out the chapters I'm not working on, so that compiling will only include the current chapter. I've adjusted the template only a very little bit. First, I need to include diacritical marks (I've decided not to use Devanāgarī, which makes things less complex). Second, I want to have a bibliography at the end of each chapter. Third, I have a few packages for tables and trees.

The basic template is structured as below:


\usepackage{amssymb} % allows symbols

\usepackage{setspace} % allows double space commands
\usepackage{polyglossia} % allows for multiple languages
\usepackage{xltxtra} % standard for nearly all XeLaTeX documents
\usepackage{utdiss2} % dissertation package
\usepackage{makeidx} % for making indexes
\usepackage{url} % for urls in bibliographies
\usepackage{qtree} % for making simple trees
\usepackage{fancyhdr} % for allowing headers and footers
\usepackage[parfill]{parskip} % Activate to begin paragraphs with an empty line rather than an indent
\usepackage{gb4e} % allows lists
\usepackage{multirow} % for tables
\usepackage{qtree} % for making simple trees


\bibpunct{}{}{;}{a}{}{,} % removes parentheses, inserts ; between multiple citations, uses author-year style, removes punctuation between author and year, inserts comma between years for multiple publications. See

(...dissertation details follow)






\nocite{*} % This command causes all items in the %
% bibliographic database to be added to %
% the bibliography, even if they are not %
% explicitly cited in the text. %
% %
\bibliographystyle{plainnat} %bibstyle must appear before including chapters to get multiple chapter bibs to work




Each document starts with \chapter{} and then contains sections and subsections, but no \begin or \end{document} is needed because they're compiled from within my main .tex file. They do all end with \bibliographystyle{plainnat} and \bibliography{diss}, though, to give me a chapter bibliography.

It's pretty simple, and the template itself includes everything from the requisite copyright page to the list of committee members. 

I'm using the author-year style of bibliography, but I need to go back through my bib file and insert curly brackets {} around the capital letters so that they're preserved, since the styles pretty much all make them lowercase.