I recently submitted my PhD thesis to the examiners. What a relief! Writing a pretty daunting task and here are a few lesssons learned on how I wrote my thesis and continue to write papers. A few starting PhD students have asked me for these advices; please find them here.
Sorting out my library
When I started at the beginning of my PhD, I used Mendeley as a reference manager. It turns out that today, this is no longer a good option; many have turned away from it, from the non-interoperability pushed by Elsevier to the laggy Word plugins, etc. For a long time, I have been looking for a new reference manager, but it turns out I could not find this. Instead, I organise my files in different folders and subfolders, depending on the research theme and topic. I find that there 2-3 subcategories are ideal: less there are too many papers per folder, more, you get lost in browsing and sorting your library. This way I can easily access the papers I am looking for without spending too much time. On top of that, I rename the pdf with the Google scholar nomenclature for bibtex entries, with author - date - first word of the title (e.g. Novoselov2004electric). In some case, two papers may share the same label; in that case I add the journal in which it was published (e.g. Novoselov2005twoPNAS). This way, it becomes quite easy to look for a paper, assuming that you have read it and know what it is about. Of course, I am only saving the papers that I decide to cite, or that I find interesting enough to be saved. For many other papers, it is just easier to google them. Some people suggested to rename your pdf with the author list, paper title, metadata, so that it is easy to find them using spotlight, but I find it is time consuming, for a marginal return.
Writing with references
The easiest way to add references is using bibtex. Once you’ve sorted all your
files using the bib-name, citing them becomes easier, for a simple reason:
Searching these key-words in Google scholar will almost all the time give you
one result only: the paper you’re citing. It is easy to copy-paste the bibtex
file provided into your library, and cite it using \cite{}
. So far, this has
been the best method I have found.
In terms of writing with TeX, I have come to adapt my text editor to my
workflow. Mostly, I’m using the indispensable
vim with a few tweaks. First,
it is important to master the shortcuts to move between words (w
, b
),
sentences ((
, )
) or paragraphs ({
, }
). There are other shortcuts that
allow to deal with text wrapping. gw
would allow to rewrap the working line;
gwap
re-wraps a whole paragraph after a few edits, and vipJ
unwraps a full
paragraph. All of this workflow might be a bit problematic when working with
git, as changing only a word can flag changes on the full paragraph. In that
case, I would recommend to use
vim-sentence-chopper.
It is also important to enable spelling. In your .vimrc
, simply add the lines:
set spelllang=en augroup latexsettings autocmd FileType tex set spell augroup END
and then use ]s
to skip to the next missspelled word. Most of the time I
find that mispelled words are a letter that is misplaced. Use xp
or xP
to move it forward or backward.
To write in LaTeX, I am using the excellent vimtex, which allows:
- completion of citations, labels, commands and easy closing of environments
- compilation using latexmk
- support of a viewer.
Concerning the viewer, I am using Skim, but note there may be different options
depending on your distribution. With vimtex, it is very easy to use
:VimtexCompile
to start auto-compile of the file, although sometimes I need
:VimtexView
to manually open the pdf. Finally, let me mention that XeLaTeX
usually deals better with fonts, especially if there are multiple in your
document (including eps/pdf figures!), therefore produces lighter pdf (you don’t
want to end-up with a 300Mb file!). To do so, place the following line at the
top of your document, and Vimtex will handle it smoothly.
%!TeX program = xelatex
Writing with collaborators
There are different option here. When writing with someone who is familiar with LaTeX, I share the file through Overleaf, and synchronise it with my Dropbox. I can edit the file locally, and it keeps updated on the overleaf interface that manages authorisations. When writing a paper with someone who doesn’t like using LaTeX, it is a bit more complicated. First, I need to convert it to a Word document using pandoc. For example, this command
pandoc -s paper.tex --citeproc --csl=./physical-review-letters.csl -o paper.docx
will generate a Word document using the PRL citation style. Then I would need to implement the changes back into the LaTeX file when I receive them, to make sure the reference are well managed. I have not had such issues recently, but I fear it may happen sooner than expected when I work with a larger pool of collaborators. If you have suggestions to automate this, I will be happy to hear about!
Productivity tweaks
Probably the best idea is to quickly start using autocompletion. YouCompleteMe
seems to be the best option here, although it is hard to set up. Use
<leader>y
and <leader>Y
to deactivate or activate it, as
indicated here. Add in your
.vimrc
:
" Turn off YCM nnoremap <leader>y :let g:ycm_auto_trigger=0 <CR> " Turn on YCM nnoremap <leader>Y :let g:ycm_auto_trigger=1 <CR>
YouCompleteMe will then activate for most of the text, which can be annoying
sometimes, but will become vital when using \cite{}
or \label{}
. With a tex
file composed of multiple dependencies corresponding to different chapters, you
will have to add the following to your .vimrc
:
if !exists('g:ycm_semantic_triggers') let g:ycm_semantic_triggers = {} endif let g:ycm_semantic_triggers.tex = [ \ 're!\\[A-Za-z]*cite[A-Za-z]*(\[[^]]*\]){0,2}{[^}]*', \ 're!\\[A-Za-z]*ref({[^}]*|range{([^,{}]*(}{)?))', \ 're!\\hyperref\[[^]]*', \ 're!\\includegraphics\*?(\[[^]]*\]){0,2}{[^}]*', \ 're!\\(include(only)?|input){[^}]*', \ 're!\\\a*(gls|Gls|GLS)(pl)?\a*(\s*\[[^]]*\]){0,2}\s*\{[^}]*', \ 're!\\includepdf(\s*\[[^]]*\])?\s*\{[^}]*', \ 're!\\includestandalone(\s*\[[^]]*\])?\s*\{[^}]*', \ ]
To conclude, the best way to write a thesis or an academic paper is —in my opinion— LaTeX with Bibtex combined with the power of vim. If you just started your PhD or are about to start, now may be the time to learn to use these tools. If your thesis is due soon, don’t bother with any of this, just write as much as you can with the editor you are the most familiar to; you will have a lifetime to learn these tools as soon as you hand in your thesis. In that case productivity tips will just slow you down as they can have a steep learning curve.
PS: Writing equations can be arduous. I have found this tutorial to improve productivity, but have not explored it.