|
| 1 | +# Template thesis |
| 2 | + |
| 3 | +> The things I'll do to avoid learning LaTeX. |
| 4 | +
|
| 5 | +This is a template for building a thesis PDF that's written in markdown, using features and styles from LaTeX. |
| 6 | + |
| 7 | +* Runs in a Docker container for portability. |
| 8 | +* Includes support for a cover page (not numbered). |
| 9 | +* Includes support for building a table of contents. |
| 10 | +* Numbers the various main sections of the document. |
| 11 | +* Includes support for LaTeX mathematics / formulae. |
| 12 | +* Includes support for citations, and a BibTex bibliography. |
| 13 | + |
| 14 | +The document is built using a Docker container that contains everything it needs. |
| 15 | + |
| 16 | +## Prerequisites |
| 17 | + |
| 18 | +The build takes place in a [Docker](https://www.docker.com/) container. |
| 19 | + |
| 20 | +Instructions for installing Docker are available below for OS X. Feel free to submit a PR with extra information for other systems. |
| 21 | + |
| 22 | +### OS X |
| 23 | + |
| 24 | +On OS X, you can install Docker Desktop using [homebrew](https://brew.sh/). |
| 25 | + |
| 26 | +1. Install homebrew: |
| 27 | + |
| 28 | + ```bash |
| 29 | + /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" |
| 30 | + ``` |
| 31 | + |
| 32 | +2. Install docker: |
| 33 | + |
| 34 | + ```bash |
| 35 | + brew install --cask docker |
| 36 | + ``` |
| 37 | + |
| 38 | +## Building your document |
| 39 | + |
| 40 | +Build the document with the `build-project.sh` script: |
| 41 | + |
| 42 | +```bash |
| 43 | +./build-project.sh |
| 44 | +``` |
| 45 | + |
| 46 | +On its first run, Docker will attempt to build the container before executing the build script that then converts your markdown to a single PDF document. |
| 47 | + |
| 48 | +The final line of a successful build indicates where to find the final output PDF: |
| 49 | + |
| 50 | +```text |
| 51 | +Output document: source/build/Sample-Project_Your-Name.pdf |
| 52 | +``` |
| 53 | + |
| 54 | +## Source files |
| 55 | + |
| 56 | +Place your source files in the `source/` directory. The build script expects to find: |
| 57 | + |
| 58 | +* `00-cover.md` - the cover page. |
| 59 | +* Files with prefix `01` to `08` - the main sections of your thesis. |
| 60 | +* `bibliography.bib` - a BibTex bibliography. |
| 61 | + |
| 62 | +NB. See sample files `05-XX-*` for an example of how to split out a large section into smaller files to make them a little easier to edit. |
| 63 | + |
| 64 | +If your structure requires more or fewer sections, edit `scripts/build.sh`, and modify the `for I` loop. |
| 65 | + |
| 66 | +## Footnotes |
| 67 | + |
| 68 | +Refer to your footnote with `[^1]` and provide the text of it anywhere in the document as: |
| 69 | + |
| 70 | +```text |
| 71 | +[^1]: this is the text |
| 72 | +``` |
| 73 | + |
| 74 | +## Citations |
| 75 | + |
| 76 | +`bibliography.bib` is a BibTex file containing your references. |
| 77 | + |
| 78 | +An easy way to obtain BibTex reference information is to search for the reference on Google Scholar. You can then obtain a BibTex reference using the `"` symbol beneath your chosen search result. |
| 79 | + |
| 80 | +To refer to something in your bibliography, use `@`-notation, and refer to the name of the entry in your bibliography, eg. |
| 81 | + |
| 82 | +```text |
| 83 | +this paper about Paralysis Proofs @ParalysisProofs |
| 84 | +``` |
| 85 | + |
| 86 | +You can also modify your references, eg. |
| 87 | + |
| 88 | +* `@Something` |
| 89 | +* `@Something [p. 45]` |
| 90 | +* `@Something [p. 45, and a suffix]` |
| 91 | +* `@Something [see also @SomethingElse]` |
| 92 | + |
| 93 | +### Citation styles |
| 94 | + |
| 95 | +Citations are styled according to `source/util/citation-style.csl`. You can see by inspection that this is a minor modification to `oxford-university-press-scimed-numerical.csl`, also in that directory. |
| 96 | + |
| 97 | +CSL styles are available at the GitHub repository: [citation-style-language/styles](https://github.com/citation-style-language/styles) |
| 98 | + |
| 99 | +The [Zotero Style Repository](https://www.zotero.org/styles) is a nice facility to help you find, preview, and download different citation styles. |
| 100 | + |
| 101 | +## Formulae |
| 102 | + |
| 103 | +The build script invokes `pandoc` with the `markdown+tex_math_dollars` option - which interprets LaTeX formulae surrounded by `$` signs. There should be no space after the opening `$` and no space before the closing `$`. eg. |
| 104 | + |
| 105 | +```latex |
| 106 | +$C_K = K + a^{2^t} \mod{n}$ |
| 107 | +``` |
| 108 | + |
| 109 | +There are plenty of resources for writing LaTeX formulae online. I found [LaTeX/Mathematics](https://en.wikibooks.org/wiki/LaTeX/Mathematics) quite helpful. |
| 110 | + |
| 111 | +## Figures |
| 112 | + |
| 113 | +To include a figure in your document, provide it as a Markdown image. The alternative text will be used as the figure's description, eg. |
| 114 | + |
| 115 | +```text |
| 116 | + |
| 117 | +``` |
| 118 | + |
| 119 | +(This aperture icon comes from [Google Fonts](https://fonts.google.com/icons?icon.query=aperture).) |
| 120 | + |
| 121 | +If you do not provide alternative text, the image will be included but not as a figure (as seen in the cover page). |
| 122 | + |
| 123 | +To adjust the size of your image, you can provide some information in a suffix to the image markdown, eg. `{ width=100px }` |
| 124 | + |
| 125 | +## The build script |
| 126 | + |
| 127 | +The docker image contains `build.sh` from `scripts/build.sh`. It's a `bash` script that does the following things: |
| 128 | + |
| 129 | +* Clears out any previous output in `source/build`. |
| 130 | +* Prepares the cover page markdown with a following page-break. |
| 131 | +* Prepares the main document markdown by combining the additional sections, separated by page-breaks. |
| 132 | +* Converts the cover page to a PDF, using `pandoc`. |
| 133 | +* Converts the main document to a PDF, using `pandoc`. |
| 134 | + * Numbers the sections. |
| 135 | + * Prefixes a table of contents. |
| 136 | + * Builds formulae using tex math. |
| 137 | + * Builds and appends citations from the bibliography. |
| 138 | +* Combines the cover page and main document using `pdfunite`. |
| 139 | +* Prints word counts from each section. |
| 140 | +* Prints the location of the final document PDF in `source/build`. |
| 141 | + |
| 142 | +Outputs from the script are found in: `source/build` |
| 143 | + |
| 144 | +NB. The script expects to find section 00 (the cover), and sections 01 to 08 (for each of the main sections). If diverging from this structure, you may need to alter the main `for I` loop in the script. |
| 145 | + |
| 146 | +## Troubleshooting |
| 147 | + |
| 148 | +**Pandoc may crash without a very meaningful error.** This could indicate that you have not assigned enough memory for Docker containers. Try increasing this assignment in Docker Desktop's Preferences / Resources page. |
| 149 | + |
| 150 | +## Contributing |
| 151 | + |
| 152 | +If you've an improvement or modification, please submit a PR. |
| 153 | + |
| 154 | +If you have any issues or suggestions, please create an issue. |
| 155 | + |
| 156 | +Feel free to fork, improve, modify, or do whatever you please with this repository. |
0 commit comments