LaTeX Dissertation Formatting Tips: Difference between revisions

From CommunityData
 
(2 intermediate revisions by the same user not shown)
Line 20: Line 20:
I used [https://yihui.org/knitr/ <code>knitr</code>] to build my tables and figures in these projects, but I did not find it necessary to include the knitr source code in my dissertation project. So when I edited these chapters, I worked on the <code>knitr</code> files (<code>.Rtex</code>) in the project repositories. To bring these changes into the dissertation, I ran knitr and then, in a manual step, edited the resulting <code>*.tex</code> files to turn them from stand-alone LaTeX projects into <code>memoir</code> chapters, as described below. I then used the <code>\input</code> LaTeX command to insert the contents of <code>.tex</code> files into the main document.  I used the git branches to track these versions of the <code>.tex</code> files.
I used [https://yihui.org/knitr/ <code>knitr</code>] to build my tables and figures in these projects, but I did not find it necessary to include the knitr source code in my dissertation project. So when I edited these chapters, I worked on the <code>knitr</code> files (<code>.Rtex</code>) in the project repositories. To bring these changes into the dissertation, I ran knitr and then, in a manual step, edited the resulting <code>*.tex</code> files to turn them from stand-alone LaTeX projects into <code>memoir</code> chapters, as described below. I then used the <code>\input</code> LaTeX command to insert the contents of <code>.tex</code> files into the main document.  I used the git branches to track these versions of the <code>.tex</code> files.


I realize I could have used a more careful organization of my LaTeX projects to avoid the manual step. ''C’est la vie.'' For simplicity, I didn’t include all the project-specific repositories here and just copied the final <code>.tex</code> files instead.<br />
I realize I could have used a more careful organization of my LaTeX projects to avoid the manual step. ''C’est la vie.'' For simplicity, I didn’t include all the project-specific stuff in <code>cdsc_examples_repositories</code> and just copied the final <code>.tex</code> files instead.<br />
If you need some help reproducing this workflow in your project, please reach out to [[User:groceryheist|Nate]].
If you need some help reproducing this workflow in your project, please reach out to [[User:groceryheist|Nate]].


== Using the <code>Memoir</code> Package ==
== Using the <code>Memoir</code> Package ==


I use the [https://ctan.org/pkg/memoir <code>memoir</code>] LaTeX package to format my dissertation as a book. You may have encountered <code>memoir</code> before if you’ve used the latex templates in the <code>cdsc_tex</code> repository that [[User:Mako|Mako]] maintains. Memoir really shines for book length projects such as your dissertation, and like a book, it is aware of when pages are on the right or the left side of the book. It comes with some attractive formatting styles, creates a fancy table of contents, and lets you insert section-specific bibliographies.
I use the [https://ctan.org/pkg/memoir <code>memoir</code>] LaTeX package to format my dissertation as a book. You may have encountered <code>memoir</code> before if you’ve used the latex templates in the <code>cdsc_tex</code> repository that [[User:Mako|Mako]] maintains. Memoir really shines for book length projects such as your dissertation, and like a book, it is aware of when pages are on the right or the left side of the book. It comes with some attractive formatting styles, creates a fancy table of contents and lets you insert section-specific bibliographies.


Following the required front matter, my dissertation opens like an academic book, with a table of contents, a list of tables and a list of figures. Memoir generates these automatically with the spell:
Following the required front matter, my dissertation opens like an academic book, with a table of contents, a list of tables and a list of figures. Memoir generates these automatically with the spell:
Line 42: Line 42:
=== References ===
=== References ===


Normally, a dissertation or other book-length project has a single bibliography at the end. So even though your articles will have their own bibliographies, you’ll want to consolidate them. Fortunately, <code>memoir</code> will do this be default. You’ll just need a single <code>\printbibliography</code> command after your last chapter.
Normally, a dissertation or other book-length project has a single bibliography at the end. So even though your articles will have their own bibliographies, you’ll want to consolidate them. Fortunately, LaTeX will do this be default. You’ll just need a single <code>\printbibliography</code> command after your last chapter.


To help show off all the work I did during my PhD that’s related to my dissertation project, I included some papers as appendices. Since these were stand-alone papers that weren’t really part of the dissertation, I printed separate bibliographies for each using the <code>\refsection</code> command. Putting an appendix in a separate <code>\refsection</code> makes <code>\printbibliography</code> print only the citations that were used within the appendix.
To help show off all the work I did during my PhD that’s related to my dissertation project, I included some papers as appendices. Since these were stand-alone papers that weren’t really part of the dissertation, I printed separate bibliographies for each using the <code>\refsection</code> command. Putting an appendix in a separate <code>\refsection</code> makes <code>\printbibliography</code> print only the citations that were used within the appendix.


I didn’t bother creating a new <code>.bib</code> file for the dissertation. I just added symbolic links to the <code>.bib</code> files for my different articles to the project and used the <code>\addbibresource</code> command. I get a lot of <code>Duplicate entry key</code> warnings from <code>biblatex</code> this way, but it’s doesn’t affect the <code>.pdf</code> output.
I didn’t bother creating a new <code>.bib</code> file for the dissertation. I just added symbolic links to the <code>.bib</code> files for my different articles to the project and used the <code>\addbibresource</code> command. I get a lot of <code>Duplicate entry key</code> warnings from <code>biblatex</code> this way, but it’s doesn’t affect the <code>.pdf</code> output.

Latest revision as of 05:20, 15 March 2022

LaTeX tips for building an electronic thesis or dissertation at the University of Washington[edit]

Note: these notes are based on Nathan TeBlunthuis’s experience dissertating in 2021. As time goes on, rules and policies might change and render all or part of this advice obsolete.

I use a Makefile and some Linux utilities to build my documents. If you’re on a different operating system and want to reproduce my workflow, you might have to install some additional software like pdftk a make utility compatible with GNU make and latekmk. The source code for my dissertation is available to CDSC members and is located in the cdsc_examples_repository.

Front matter[edit]

The only hard formatting requirements for the electronic thesis or dissertation (ETD) are the copyright, title, and abstract pages. You can get Microsoft Word templates for each these pages from the graduate school or, as I did, you can use a template in a single Word File maintained by Alex Mamishev, Professor in Electrical Engineering.

I filled out the template and then exported the copyright, title_page, and abstract as separate .pdf files. I build a single pdf with all of my chapters and then use pdftk to staple on the front matter:

pdftk copyright_page.pdf title_page.pdf abstract.pdf ETD_version.pdf cat output diss_ecology_of_online_communities.pdf

Project Organization[edit]

You probably want to break your dissertation up into several different .tex files. Although I prefer to work on paper-length projects of 8,000 to 14,000 words or so in a single file, for a book or dissertation-length project it clearly makes more sense to keep each chapter in a different file. Building a very large .tex project can take too long. Very long files are more cumbersome to edit, even when using a powerful editor like Emacs. You are likely to publish different chapters as stand-alone articles. Indeed, the central 3 chapters of my dissertation were composed as stand-alone research articles, and two of them were under review when I defended.

To synchronize the publication and dissertation versions of these articles, I created a special git branch in the repositories for each project. The sole purpose of these branches was to make it convenient to merge any changes I made to the articles into the dissertation.
I added the .tex files from these project-repositories into my dissertation project using a symbolic links.
I used knitr to build my tables and figures in these projects, but I did not find it necessary to include the knitr source code in my dissertation project. So when I edited these chapters, I worked on the knitr files (.Rtex) in the project repositories. To bring these changes into the dissertation, I ran knitr and then, in a manual step, edited the resulting *.tex files to turn them from stand-alone LaTeX projects into memoir chapters, as described below. I then used the \input LaTeX command to insert the contents of .tex files into the main document. I used the git branches to track these versions of the .tex files.

I realize I could have used a more careful organization of my LaTeX projects to avoid the manual step. C’est la vie. For simplicity, I didn’t include all the project-specific stuff in cdsc_examples_repositories and just copied the final .tex files instead.
If you need some help reproducing this workflow in your project, please reach out to Nate.

Using the Memoir Package[edit]

I use the memoir LaTeX package to format my dissertation as a book. You may have encountered memoir before if you’ve used the latex templates in the cdsc_tex repository that Mako maintains. Memoir really shines for book length projects such as your dissertation, and like a book, it is aware of when pages are on the right or the left side of the book. It comes with some attractive formatting styles, creates a fancy table of contents and lets you insert section-specific bibliographies.

Following the required front matter, my dissertation opens like an academic book, with a table of contents, a list of tables and a list of figures. Memoir generates these automatically with the spell:

\tableofcontents
\listoffigures
\listoftables

Following these tables and lists, I have an “Acknowledgments” section and a “Dedication.” I created these with the \chapter* command. \chapter starts a new chapter on the next right-hand page and adds the chapter to the table of contents. \chapter* does the same, but leaves the chapter out of the table of contents. I also used \chapter* to insert prefaces for each chapter that note if the chapter is published, has been presented and credit my collaborators.

Converting Articles into Memoir Chapters[edit]

As described above, I used the \input command to insert a .tex file for chapter into the main document. Each stand-alone article has its own LaTeX preamble, which begins with a \documentclass command and ends with \begin{document}. Since I built my dissertation as a single document, I stripped the preambles from each chapter file and added any dependencies from any of my projects to the preamble of the main file (ETD_version.tex). I also removed \end{document} and \printbibliography commands from the end of the file.

Finally, chapters don’t normally have abstracts, and the \abstract command doesn’t work to insert an abstract in each chapter. Fortunately, you can use the \chapterprecishere command provided by memoir to insert an abstract at the beginning of the chapters.

References[edit]

Normally, a dissertation or other book-length project has a single bibliography at the end. So even though your articles will have their own bibliographies, you’ll want to consolidate them. Fortunately, LaTeX will do this be default. You’ll just need a single \printbibliography command after your last chapter.

To help show off all the work I did during my PhD that’s related to my dissertation project, I included some papers as appendices. Since these were stand-alone papers that weren’t really part of the dissertation, I printed separate bibliographies for each using the \refsection command. Putting an appendix in a separate \refsection makes \printbibliography print only the citations that were used within the appendix.

I didn’t bother creating a new .bib file for the dissertation. I just added symbolic links to the .bib files for my different articles to the project and used the \addbibresource command. I get a lot of Duplicate entry key warnings from biblatex this way, but it’s doesn’t affect the .pdf output.