Setup: New Article - JonasEngstrom/overleaf-article-template GitHub Wiki

  1. Log into Overleaf

  2. Click New Project in the upper left-hand corner.

  3. Choose Blank Project.

  4. Give it a name and click Create.

  5. If you want to use Zotero or Mendeley for automatic reference management, click the paper icon with the tool tip New File in the upper left-hand corner and choose From Zotero or From Mendeley as appropriate. Keep the name of the file as references.bib. Choose BibLaTeX as format (although BibTeX should also work.) Click Create.

[!TIP] If GitHub Command Line tools are installed, this script can be run to speed up the following steps. Just download the script to the desired parent directory and run the command ./setup_new_article.sh <desired_project_name> "<Overleaf URL>". For instructions on how to find the Overleaf URL, see steps 15-17 below. The script file can be deleted, once it has been run." To download the script directly from the terminal the following command can be used curl -OL https://raw.githubusercontent.com/JonasEngstrom/overleaf-article-template/main/setup_new_article.sh.

  1. In a new web browser tab go to https://github.com/JonasEngstrom/overleaf-article-template/generate.

  2. Give the repository a name and choose whether you want it to be public or private.

  3. Click Create repository.

  4. Click the Code button.

  5. Copy the HTTPS or SSH link.

  6. Open a terminal prompt.

  7. Navigate to the directory where you want to store your project.

  8. Run the commands:

    git clone --recursive <paste link copied from GitHub here> <desired name of local directory>
    cd <name of the newly cloned directory>
    
  9. If you have not previously used Git with Overleaf, follow the steps described here first. Note that this only needs to be done once (and again when the authentication token expires after a year).

  10. Go back to the Overleaf tab of the web browser.

  11. Click Menu in the upper left-hand corner.

  12. Copy the link under Git authentication tokens (i.e. the one containing an @ symbol). Make sure not to copy the preceding git clone.

  13. Go back to the terminal prompt and run the command (note that the message Initial commit. can be changed to your liking):

    ./sync.sh "Initial commit."
    
  14. When prompted Enter Overleaf SSH or HTTPS address:, paste the link copied from Overleaf and press enter.

  15. You should now be ready to use your new project in RStudio, by opening main.Rproj. The article text is in the R Markdown file main.Rmd. To stage and commit files to both GitHub and Overleaf, simply run the sync.sh script again, using the command under step 18 above. Note that you need to run knitr inside RStudio before running sync.sh for changes to show up on Overleaf.

[!NOTE] Do not give co-authors write access on Overleaf, but rather add them to the project on GitHub, to avoid having merge conflicts break synchronization.

[!IMPORTANT] If you want your article to not be licensed under an MIT license, remember to change the LICENSE file before adding any original work.

Protecting the Main Branch

If you want to protect the main branch, so that that all commits to main require a pull request from another branch (which is probably a good idea if there is more than one author), you can do so under Settings in the repo. It makes working according to the GitHub Flow more straight forward.

[!NOTE] Branch protection rules will not be enforced for private repositories, unless you have an Enterprise or Team plan.