<commit_before>---
layout: post
title: Notes on typesetting my thesis with latex
---

For my MSc dissertation, the official template is a Word document. For quite a long time, I have not used Word if I am the only one editing that document.

So many choices are out there. I personally use the following combinations for text editing:

* **Plaintext w/o [markdown](http://daringfireball.net/projects/markdown/) syntax** for notes, assignments without format specs, drafts for long documents and the source of current page you are viewing
* **Emacs [org-mode](http://orgmode.org/)** for documents which I have created earlier with that. E.g., a log of my expenses, some notes on lectures or weekly seminars. (I used to keep my TODO list in org-mode. Now I am using [doit.im](http://doit.im).)
* **Google Docs** for collaborating with others.
* **LaTeX** for serious things like reports or papers.

Writing with latex is usually painless. It is even more convenient when there are tools like [pandoc](http://johnmacfarlane.net/pandoc/) which help convert my markdown drafts to latex articles. (That's how I use pandoc. It can do far more than that. Org-mode has latex export functionally as well.) However, when there's a "Word template" and the submitted electronic/printed copy must follow those requirements, you'd better pray there's an existing latex class that does all the nasty format adjustments. Unfortunately, I found nothing. No such classes for any kind of documents for HKPU. (There is a Beamer theme by <NAME>. I saw him using it in our weekly seminar and then found it at [GitHub](http://github.com/quxiaofeng/PolyU_Beamer_Theme).)

I started with [puthesis](http://engineering.purdue.edu/~mark/puthesis/) class and changed whatever I find different from the official Word template. There are still some minor differences. (If not, what's the point of using late….) I'll leave this to the department general office to judge whether it is acceptable and make further changes to fulfill the requirements. If it is accepted, I'll share this document class on GitHub.

Various packages are used, if you are new to latex, read [the tex environment part](#latexenv) first for setting up a latex environment that is fully automatic.

Most of the changes are straightforward. Just search the need in natural language, e.g. "how to change chapter heading font size" and you get an answer. Some require a more recursive searching process. You look for a specific setting. Someone replies with an keyword and left. Follow that keyword and you may find a more detailed description.

<a id="latexenv"></a> <!--just an anchor for internal link-->
# The latex environment that works for me
There are various tex distributions. I have the following setup for my computers.

## Mac

[MacTeX](http://tug.org/mactex/).

If some command line tools are missing, I try [Homebrew](http://mxcl.github.com/homebrew/) first.

I use [TextMate](http://macromates.com/) at the moment. Sometimes I use [Aquamacs](http://aquamacs.org/). I used to use [TeXShop](http://pages.uoregon.edu/koch/texshop/).

For PDF preview, the built-in Preview.app works. If you want something else, [Skim](http://skim-app.sourceforge.net/) might be a good one.

## Windows

There are times that I might want to check whether everything works under Windows.

Then I use [MiKTeX Portable](http://miktex.org/portable/about). The basic install takes much less storage than the greedy MacTeX. If a package is required, it will download and install automatically in the background. I am using the portable version because I have it synced via Dropbox. When I need a tex environment on someone else's computer, I can simply download the folder from dropbox and start using it.

The only thing that requires manual setup for this post is the `pygmentize` command for `minted` highlighting. No big deal, use `listings` instead. Or, install Python, `easy_install` and `Pygment`, configure the `PATH` and `minted` will work.

# HOWTOs

Shortcuts

* [PDF 1.4, Acrobat 5.x Compatibility](#pdf14)
* [Include EPS image](#eps)
* [Table caption position and separator](#tab)
* [Set line spacing](#linespace)
* [Remove first-line indentation, modify after paragraph skip](#parskip)
* [Page number position](#pageno)
* [Set page margins](#margin)
* [Format chapter headings, text shadow](#chap)
* [Format section, subsection, etc. headings](#headings)
* [Format Bibliography heading](#bib)
* [Format Appendix heading](#appdix)
* [Format Table of Contents, List of Figures, List of Tables](#toc)
* [Turn on/off code highlighting](#bw)
* [Specify a TeX root document](#root)

<a id="pdf14"></a> <!--just an anchor for internal link-->
## Create PDF outputs compatible with Acrobat 5.x or above

The default PDF version of pdflatex output is 1.5 (Acrobat 6.x+). To go back and use PDF 1.4, add this:
<pre class="prettyprint linenums"><code class="lang-tex">\pdfminorversion=4
</code></pre>

Alternatively, there is a package for this issue. Simply put the following line right after the `\documentclass` declaration. Some say that putting this after using other packages leads to errors. I am not sure about that. I am happy with the `\pdfminorversion` one and am not interested in moving the line around to get things broken...
<pre class="prettyprint linenums"><code class="lang-tex">\RequirePackage{pdf14}<commit_msg>test pygments syntax highlighting<commit_after>---
layout: post
title: Notes on typesetting my thesis with latex
---

For my MSc dissertation, the official template is a Word document. For quite a long time, I have not used Word if I am the only one editing that document.

So many choices are out there. I personally use the following combinations for text editing:

* **Plaintext w/o [markdown](http://daringfireball.net/projects/markdown/) syntax** for notes, assignments without format specs, drafts for long documents and the source of current page you are viewing
* **Emacs [org-mode](http://orgmode.org/)** for documents which I have created earlier with that. E.g., a log of my expenses, some notes on lectures or weekly seminars. (I used to keep my TODO list in org-mode. Now I am using [doit.im](http://doit.im).)
* **Google Docs** for collaborating with others.
* **LaTeX** for serious things like reports or papers.

Writing with latex is usually painless. It is even more convenient when there are tools like [pandoc](http://johnmacfarlane.net/pandoc/) which help convert my markdown drafts to latex articles. (That's how I use pandoc. It can do far more than that. Org-mode has latex export functionally as well.) However, when there's a "Word template" and the submitted electronic/printed copy must follow those requirements, you'd better pray there's an existing latex class that does all the nasty format adjustments. Unfortunately, I found nothing. No such classes for any kind of documents for HKPU. (There is a Beamer theme by <NAME>. I saw him using it in our weekly seminar and then found it at [GitHub](http://github.com/quxiaofeng/PolyU_Beamer_Theme).)

I started with [puthesis](http://engineering.purdue.edu/~mark/puthesis/) class and changed whatever I find different from the official Word template. There are still some minor differences. (If not, what's the point of using late….) I'll leave this to the department general office to judge whether it is acceptable and make further changes to fulfill the requirements. If it is accepted, I'll share this document class on GitHub.

Various packages are used, if you are new to latex, read [the tex environment part](#latexenv) first for setting up a latex environment that is fully automatic.

Most of the changes are straightforward. Just search the need in natural language, e.g. "how to change chapter heading font size" and you get an answer. Some require a more recursive searching process. You look for a specific setting. Someone replies with an keyword and left. Follow that keyword and you may find a more detailed description.

<a id="latexenv"></a> <!--just an anchor for internal link-->
# The latex environment that works for me
There are various tex distributions. I have the following setup for my computers.

## Mac

[MacTeX](http://tug.org/mactex/).

If some command line tools are missing, I try [Homebrew](http://mxcl.github.com/homebrew/) first.

I use [TextMate](http://macromates.com/) at the moment. Sometimes I use [Aquamacs](http://aquamacs.org/). I used to use [TeXShop](http://pages.uoregon.edu/koch/texshop/).

For PDF preview, the built-in Preview.app works. If you want something else, [Skim](http://skim-app.sourceforge.net/) might be a good one.

## Windows

There are times that I might want to check whether everything works under Windows.

Then I use [MiKTeX Portable](http://miktex.org/portable/about). The basic install takes much less storage than the greedy MacTeX. If a package is required, it will download and install automatically in the background. I am using the portable version because I have it synced via Dropbox. When I need a tex environment on someone else's computer, I can simply download the folder from dropbox and start using it.

The only thing that requires manual setup for this post is the `pygmentize` command for `minted` highlighting. No big deal, use `listings` instead. Or, install Python, `easy_install` and `Pygment`, configure the `PATH` and `minted` will work.

# HOWTOs

Shortcuts

* [PDF 1.4, Acrobat 5.x Compatibility](#pdf14)
* [Include EPS image](#eps)
* [Table caption position and separator](#tab)
* [Set line spacing](#linespace)
* [Remove first-line indentation, modify after paragraph skip](#parskip)
* [Page number position](#pageno)
* [Set page margins](#margin)
* [Format chapter headings, text shadow](#chap)
* [Format section, subsection, etc. headings](#headings)
* [Format Bibliography heading](#bib)
* [Format Appendix heading](#appdix)
* [Format Table of Contents, List of Figures, List of Tables](#toc)
* [Turn on/off code highlighting](#bw)
* [Specify a TeX root document](#root)

<a id="pdf14"></a> <!--just an anchor for internal link-->
## Create PDF outputs compatible with Acrobat 5.x or above

The default PDF version of pdflatex output is 1.5 (Acrobat 6.x+). To go back and use PDF 1.4, add this:

```latex
\pdfminorversion=4
```

Alternatively, there is a package for this issue. Simply put the following line right after the `\documentclass` declaration. Some say that putting this after using other packages leads to errors. I am not sure about that. I am happy with the `\pdfminorversion` one and am not interested in moving the line around to get things broken...
<pre class="prettyprint linenums"><code class="lang-tex">\RequirePackage{pdf14}
{'fraction_non_alphanumeric': 0.0891737625152054, 'fraction_numerical': 0.0029942921306259944, 'mean_word_length': 4.560874089490114, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3096589', 'n_tokens_mistral': 2996, 'n_tokens_neox': 2788, 'n_words': 1491}