LaTeX

In attempt to offset the extent to which I have benefited from others’ online instructions about how to use and customise LaTeX, I have listed below some of the resources that I have collected. In particular, I will provide detailed instructions for how to connect LaTeX and Zotero so that with a single click, one may: (i) download a pdf, complete with bibliographic information from journal websites; (ii) store that pdf and bib info in your Zotero database; such that (iii) the source is instantly available to cite via BibTex. I will also include some of the templates, macros, and style packages that I find useful. I will indicate differences for Mac and Window users were differences occur.

  1. Download and instal the LaTeX distribution for your operating system.
  2. Create the ‘texmf’ folder tree in your directory.
    1. For Mac users:
      1. You will first need to locate your main ‘Library’ folder in Finder. Begin by opening a new Finder window. Press cmd+shift+h to go to the home folder, and cmd+j to open an options window. Check ‘show Library folder’.
      2. Then create a folder called ‘texmf’ in your Library if it is not already there, and another folder called ‘bibtex’ inside texmf. Inside bibtex, create folders called ‘bib’ and ‘bst’. Inside bst, place this style file which comes from here.
      3. Now add this template to Library -> TexShop -> Templates. This template includes the commands \bibliographystyle{Analysis} and \bibliography{Zotero} at the end of the document which will look up the file you places in the bst folder as well as the bibliography you will place in the bib folder in 5C below.
    2. For Windows users:
      1. In C, create a folder called ‘texmf’, and another folder called ‘bibtex’ inside texmf. Inside bibtex, create folders called ‘bib’ and ‘bst’. Inside bst, place this style file which comes from here.
      2. Now add this template to Users -> {user name} -> AppData -> Local -> MikTex -> 2.9 -> TexWorks -> 0.4 -> Templates. This template includes the commands \bibliographystyle{C:/texmf/bibtex/bst/Analysis} and \bibliography{C:/texmf/bibtex/bib/Zotero} at the end of the document which will look up the file you places in the bst folder as well as the bibliography you will place in the bib folder.
      3. If you want to save the bst and bib files elsewhere, you will need to change the path in the template file. Note the forward slashes in place of backslashes. You can also substitute other bst (bibliography style) files for Analysis.bst such as this one.
  3. Download and instal Zotero 4 together with a plugin for your preferred browser.(Note: Zotero 5 is not compatible with Better BibTex as of Nov 2017.) Firefox is optimised for Zotero with a pop-up toolbar, however I prefer the low profile that Zotero keeps in Chrome or Safari.
  4. Now run a simple test:
    1. Find a paper you would like to download. If you use a VPN provided by your research institution, make sure that it is turned on, and if you use an AdBlocker, make sure that it is not blocking pop-ups for the journal’s website.
    2. Before downloading the paper as you normally would, notice the small Zotero icon in the top-right of your browser. If Zotero has located a single paper, the icon will look like a paper; if it has located multiple, it will look like a folder.
    3. Click the icon and, if need be, select the desired paper. If all goes as it should, a small banner will pop up in the lower right-hand side of the screen that indicates that it has scraped the bib data and downloaded your file.
    4. Now switch from your browser to Zotero to check if the bib info (with the pdf) showed up. If it did not work, or did not grab the pdf with the bib data, make sure you are appropriately logged on to the journal website and repeat. For instance, if you are unable to download the pdf in the old fashioned way, then Zotero will not be able to download the pdf either. If problems persist, you can look for further answers here. You can also always add the file manually to the bib info, if the website is being fussy (Jstor is terrible!).
    5. Once you are able to capture bib data, make sure to check that the website provided complete information, and that there are no obvious errors or missing fields. (I don’t typically check that all the bib information is correct.)
  5. Download the Better BibTex plugin, installing the package by clicking Add-ons in the the ‘Tools’ menu bar at the top of your screen when Zotero is open. In the Add-ons manager, click the gear dropdown menu, selecting ‘Install add-on from file’. Select the .xpi file you just downloaded. Restart Zotero.
    1. Now click the gear drop down menu in the main Zotero window and select ‘Preferences’. Open up the ‘Better BibTex’ tab just to the right of ‘Advanced’. Under the ‘Citation’ sub-tab, replace the citation key format with this: [auth][year]. (For other options, you can look up the syntax. Further information can also be found here.) Also check ‘On item change’ at the bottom left.
    2. Now switch to the ‘Automatic Export’ sub-tab and check ‘On Change’. This means that the instant you update your database with a new bib entry, or edit an old bib entry, Zotero will update the .bib files where your database is exported. If your library is extremely large, this could be slow, and so you might want to select the ‘When Idle’ option. But I have no troubles with the ‘On Change’ feature.
    3. Close the Preferences window, returning to the main Zotero window. Right-click the main library folder in the left-most blue column, selected ‘Export Library’ (alternatively you can export other project folders, but I like to keep things simple). Under the ‘Format’ dropdown menu, select ‘Better BibTex’. Then check the ‘Keep Updated’ box. Save the file as ‘Zotero’ (the extension will be added automatically) to the bib folder that you previously created.
  6. Open TexShop and create a new file (or create a file from template in TexWorks). In the ‘Templates’ drop-down menu, select PhilArticle. Press cmd+T (or click ‘Typeset’). Save the document in a new folder with the appropriate project name.
    1. If the file does not run, open TexLive Utility in the Tex folder in the Applications folder, and update. Restart everything and try to typeset the file again.
    2. Occasionally, it can also help to click Trash Aux Files in the error console, if the pdf is not generating properly.
  7. Once your file typesets, open Zotero and click on one of the files in your library, and look for the ‘Citation Key’ in the details. If no key is present, or the key data is not of the form [auth][year], you can right-click the file in your library and click ‘Generate BibTex Key’. It should look like ‘Fine1994a’. Once you have the key, you can cite that paper by writing ‘\citet{Fine1994a}’ (without quotes) in the new tex file.
    1. To list multiple sources by the same, or different authors, separate the cite keys with a comma such as: ‘\citet{Fine1994a,Fine1995,Fine1995b}’.
    2. For other citation styles, refer to the preamble of the PhilArticle template for further commands, e.g., ‘\citep’, etc.
    3. It can also be helpful to customize commands as exemplified in the preamble of the PhilArticle template provided above. I have included a definition of \citepos which is useful for making citation names possessive.
  8. In TexShop, you will need to hit cmd+T, then cmd+shift+b, then cmd+T, and the cmd+T for a final time. You should see both the citation you added in the text as well as the full citation in the references. Why all the command combinations? The first cmd+T will update the .tex file you are working on, adding the citation key. The cmd+shift+b will look up the citation key in your master Zotero.bib file saved in the bib folder. Then another cmd+T will import the citation data, and the final cmd+T will typeset it altogether. Sound clunky? It is at first, but becomes really natural and easy. (I highly recommend Sublime Text 3 (ST3) which has lots of nice features— e.g, does all the compiling at once— and takes integration with Zotero one step further, allowing you to look up citations without leaving the editor, or even having to use the mouse. There are lots of good youtube videos for installation.)
  9. Want to check how many words your document has? Open the ‘Macros Editor’ under the ‘Macros’ toolbar in TexShop. Select ‘New Item’ giving it a name like ‘TexCount’ and dragging it from the bottom of the list (left column) up to the top. Then cut and paste this into the content. Many more macros can be found here. (TexWorks does not currently offer macros support.)
  10. Now you are ready to tex! If you get stuck, get used to googling things and reading the bottom of the error console. I would also suggest making notes in the preamble of your template file of the really useful bits that you learn in order to instruct your future self. By adding a ‘%’ symbol after the new bit of code you add to the preamble, you can explain what it does so that next time you will remember. Lots of helpful information is also available here and here, including a nice lookup guide.

Happy texing!

Here is a link to some further resources.