Skip to content

Using ShareLaTeX.com

Cameron Chisholm edited this page Oct 27, 2016 · 25 revisions

This page shows you how to use the ShareLaTeX.com IDE for Grattan reports.

How to get started

Register for ShareLaTeX

Open an account on https://www.sharelatex.com/register. It is free to register, but talk to AMac about getting a paid account, which has the following features:

  • Dropbox and GitHub sync
  • full history and track changes
  • Mendeley sync (for references)
  • faster compile time
  • bibliography search

To begin a new report, first go to https://github.com/HughParsonage/grattex/releases/ The page should look like

grattex-release-page

Under the latest release, download the .zip file.

Then go to https://www.sharelatex.com/project and Create New Project or New Project > Upload project. Choose the .zip file button and upload your .zip file.

click 'New Project' and select 'Upload Project'. There is a .zip file available at Z:\Templates\Report that can be uploaded for this purpose. It is also possible to download the latest report template from https://github.com/HughParsonage/grattex.

Note that ShareLaTeX updates in real time. This means it is not necessary to save your work as you go.

Adding co-authors

If you are the 'owner' of the document, you can invite others to collaborate. If you have a document open in ShareLaTeX, there is an icon you can click near the top right to add collaborators.

Navigating the ShareLaTeX editor

The editor is divided into three windows. It is possible to manually adjust the width of each (e.g. some prefer the output window to be larger, while others prefer the source code to be larger).

Repository

On the left is the 'repository', containing all the files used in the creation of the document: those containing text/source code (.tex files), the bibliography (.bib), charts and images (saved as PDFs under 'atlas'), and the Grattan report formatting (grattan.cls).

Source code

The middle window contains the source code of the file that is currently open (highlighted in the repository). You can open the source code of a different file simply by clicking on it in the repository. The file 'main.tex' is the file that ShareLaTeX will compile whenever you click 'recompile', even if another file is open at the time. ShareLaTeX also gives you line numbers in your source code, which can be useful when dealing with compile errors.

Output

The window on the right gives you a preview of the most recently compiled document (the PDF output). It is also possible to download this PDF if you prefer to view it at a higher resolution. Note that double clicking anywhere on text in the PDF will take you to the location in the source code.

Menu

The menu can be found at the top left of the screen. From here it is possible to change the font size and colour scheme of the editor, as well as link your Dropbox, GitHub, and Mendeley accounts.

Adding new elements to the document

Adding a chapter

The report template has four .tex files for chapters (named chap1, chap2, chap3, chap4). The file 'main.tex' links to these files using \input chap1, \input chap2, etc. If you want to change the name of the chapters, right click on the chapter file in the repository and select 'rename'. You will also need to rename the file in 'main.tex'.

Underneath the menu at the top left of the screen is an icon that lets you insert a 'new file'. You will need to include the extension (.tex) when naming the file. Having created a new chapter, you will then need to edit 'main.tex' – type \input new_chapter (where 'new_chapter' is the name of the file you've created) in the location where you want this chapter to appear.

Adding charts

Charts should be included as .pdf files. If you use PowerPoint to create charts, save your chartpack to the folder 'atlas' as a PDF file (the easiest way to do this is via the Dropbox folder where your document is stored). Unlike .tex files, you cannot simultaneous edit PowerPoint files that are stored in ShareLaTeX. If you have multiple people working on charts, it is best to use multiple files.

To insert a chart from the chartpack, use the command:

\includegraphics[page=X]{atlas/chartpack.pdf}

where 'chartpack.pdf' is the filename of your chartpack, and 'X' is the page number of the chart you want to insert.

To put your chart in a figure environment, copy and paste the following code and edit accordingly:

\begin{figure}
\caption{Chart title}
\units{Chart subtitle}
\includegraphics[page=X]{atlas/chartpack.pdf} \label{fig:chartXref}
\notes{Notes}
\source{Grattan analysis of \textcites{source1}{source2}}
\end{figure}

where 'X' refers to the slide number of the chart, 'chartpack.pdf' is the filename of the chartpack, 'fig:chartXref' is the cross-reference label applied to the chart, while 'source1' and 'source2' are reference keys (use \textcite{} rather than \textcites{}{} if you only have a single source).

If you make an update to your charts in PowerPoint, all you need to do it overwrite the .pdf file and LaTeX will update the charts on the next compile.

Adding references

References are stored in a .bib file. The template includes a file bibliography.bib with some example references, but it is possible to add a new bibliography (and there is no limit to how many bibliographies you can have). To add a new bibliography, click 'new file' and save it to your repository using a .bib extension. You will need to add a line to 'preamble.tex' to ensure that LaTeX will read your bibliography:

\addbibresource{bibliography_name.bib}

There are a number of ways you can add a new reference to a bibliography.

From scratch

LaTeX has many reference types that can be added to a bibliography, but nearly all references can be inserted using one of two types: 'misc' (miscellaneous - best for reports, websites, etc.) 'article' (for journal and newspaper articles). To insert a new reference into your bibliography from scratch, copy and paste one of the following lines of code into the .bib file (at the top of the file is fine) and edit accordingly:

@misc{referencekey,
   title={Modelling the impacts of a cut to company tax in Australia},
   author={Dixon, J. M. and Nassios, J.},
   year={2016},
   note={Centre of Policy Studies Working Paper No. G-260, April 2016},
   url={http://www.copsmodels.com/ftp/workpapr/g-260.pdf}
}
@article{referencekey,
   title={Why do management practices differ across firms and countries?},
   author={Bloom, N. and Van Reenen, J.},
   journal={The Journal of Economic Perspectives},
   volume={24},
   number={1},
   pages={203--224},
   year={2010},
   url={https://www.aeaweb.org/articles?id=10.1257/jep.24.1.203}
}

It is not necessary to include every field in the bibliography entry. Note that each field is separated by a comma, not the line break – if you exclude the comma between any fields you will encounter an error. For the referencekey, you are free to type anything, but it is good practice to use 'AuthorYearTitle', e.g. 'Bloom2010Management' for the example above.

From Google Scholar

If you find an article on Google Scholar, it is possible to import this into your bibliography. From the search page, find the article, click 'cite', then 'import into BibTeX'. From here, just copy the code straight into your .bib file. However, there are often mistakes in the fields, so it is a good idea to check.

From Mendeley or an external reference manager (e.g. JabRef)

ShareLaTeX integrates with a reference manager called Mendeley. If you sign up for a Mendeley account, this can be synced to your ShareLaTeX account – a .bib file will be created with all of the references that are stored in your Mendeley account.

If you find inserting references using code challenging, there is a desktop program called 'JabRef' that operates similarly to EndNote in the way that references are entered. Because it is run on the desktop, the bibliography should be managed by a single team member (to avoid conflicts).

Insert a reference into the document

To insert a reference(s) as a footnote, use the following code:

\footcite{source1}

or

\footcites{source1}{source2}

or

\footcites[][11]{source1}[][22--35]{source2}

where 'source1' and 'source2' are the reference keys in the .bib file. Including [][##] will add page numbers to the reference (the example above would produce p. 11 and pp. 22-35).

To insert a reference in the text, within a chart source, or within a longer footnote, use \textcite{} or \textcites{}{} in the same way.

Editing and version control

Because ShareLaTeX updates in real time, multiple authors can work on the document at the same time. This means the online version is always the 'master'. It is possible to draft in another program (e.g. Microsoft Word) and then upload text to ShareLaTeX.

Adding comments to the PDF

First, you need to add two commands that allow you to add comments:

\newcommand{\name}[1]{\todo[color=Color2,size=\scriptsize]{\textbf{Name:} #1}}
\newcommand{\namei}[1]{\todo[color=Color2,size=\scriptsize,inline]{\textbf{Name:} #1}}

Replace 'name' with your own Name. You can also change the background colour of the comments (Color1, Color2, Color3 and Color4 are usually best).

There are two types of comments. A margin comment (\name) will appear in the document margin, while an inline comment (\namei) will appear within the text. You cannot use margin comments within footnotes, the overview, boxes or figure environments – use inline comments instead. Comments are also listed at the beginning of the document.

To turn off all comments in the document, go to 'preamble.tex' and change:

\usepackage{todonotes}

to

\usepackage[disable]{todonotes}

(it is still a good idea to remove comments as they are resolved, and ensure the final .tex file has no remaining comments).

Using track changes

ShareLaTeX automatically tracks all changes of LaTeX files (.tex, .bib, and .cls) by user – use the icon in the top right corner to view changes (you can select the start and end point of changes you wish to view). This is quite useful to see which part of the report others are working on as well as viewing any recent changes. You can specify the beginning and end point of the changes you wish to view.

The downside of the track changes feature is that it does not allow for in-line editing while track changes are being viewed. If you have multiple monitors, one option is to open a separate ShareLaTeX window on each screen and use one screen to view track changes, and the other screen to edit.

Saving a pre-edited version

When the document is first sent for editing, an advantage of ShareLaTeX is that all co-authors can continue working on the document – it is not necessary to cease working on the document until all edits are complete. As an example of how this might work, the editor could edit Chapter 1 while the team continues working on other chapters. Once the Chapter 1 edits are complete, the editor can move onto Chapter 2, while someone from the team can review the edits of Chapter 1. This process then continues for all chapters.

Nonetheless, it is a good idea to save a pre-edited version of each chapter that can be compared to the post-edited version. While track changes can be used to view edits, it is easier to copy and paste original text from a pre-edited version (if desired).

There are a number of ways of saving a pre-edited version:

Create a backup offline

Under the menu, choose 'Download, Source' and save the file to your hard drive (or to a separate dropbox folder).

Create a backup on ShareLaTeX

Under the menu, choose 'Action, Copy Project', and choose an appropriate name (e.g. Project Name Date pre-chap1-edits). A separate document will be stored in ShareLaTeX with the current state of the project.

Create a backup on GitHub

There are two major advantages of using GitHub as a backup for ShareLaTeX. The first is that you can 'save' the current state of the project at any point in time (e.g. immediately before and after each chapter is edited), and all of these states can be viewed at any point in the future. The second is that you can compare two alternative states of the project and easily view the differences (this is similar to viewing track changes).

To use GitHub as a backup, you need to link a GitHub account (menu, sync, GitHub). Talk to HP about using the Grattan GitHub account. Whenever you wish to save a current version of the project, use 'menu, sync, GitHub' and 'push changes to GitHub'.

Debugging (specific to ShareLaTeX)

Dealing with errors and warnings

Dealing with slow compile times or compile timeouts

Working offline