Skip to content

Instantly share code, notes, and snippets.

@sugatoray
Last active January 8, 2023 17:42
Show Gist options
  • Save sugatoray/5c9ec0d837bb0cc98bc7d98544a91c6f to your computer and use it in GitHub Desktop.
Save sugatoray/5c9ec0d837bb0cc98bc7d98544a91c6f to your computer and use it in GitHub Desktop.
Open LaTeX in Overleaf directly from GitHub

overleaf-badge-image

Example badge: open-in-overleaf

Overleaf is an online service that allows you to create/edit/collaborate on LaTeX documents. For details on how the badge must be used, see the Example below.

  • Sample badge: Open in Overleaf

Overleaf API

Overleaf also provides an API (application programming interface) that can be used to open any online LaTeX (.tex) document directly on Overleaf.com. Please see the Overleaf api docs for further details.

To keep things short, we could use the following api end-point(s):

  • Single File

    Syntax: https://www.overleaf.com/docs?snip_uri=http://pathtoyourfile.tex

    1. Example: Open a single .tex file using overleaf-api.

      https://www.overleaf.com/docs?snip_uri=https://github.com/posquit0/Awesome-CV/blob/master/examples/resume.tex

      badge: Open in Overleaf

    2. Example: Open a single .zip file using overleaf-api.

      https://www.overleaf.com/docs?snip_uri=https://github.com/k4rtik/latex-project-report-template/archive/refs/heads/master.zip

      badge: Open in Overleaf

  • Multiple Files

    Multiple files can be uploaded to overleaf with the snip_uri[] array parameters.

    https://www.overleaf.com/docs?snip_uri[]=http://.../a.tex&snip_uri[]=http://.../b.tex
    1. Example: Open a list of .tex files using overleaf-api.

      https://www.overleaf.com/docs?snip_uri[]=https://github.com/posquit0/Awesome-CV/blob/master/examples/resume.tex&
                                    snip_uri[]=https://github.com/posquit0/Awesome-CV/blob/master/examples/coverletter.tex

Resources for overleaf-badge

I used some of the content from the following links to create the overleaf-badge.

Example overleaf-badge:

The following badge (open-in-overleaf) opens a github repository directly in Overleaf.com. If you do not have an account, you can sign up for one for free.

Open in Overleaf

The following code snippet was used in markdown to create this overleaf-badge.

[![Open in Overleaf][#overleaf-badge]][#github-repo-zip]

[#overleaf-badge]: https://tinyurl.com/overleaf-badge
[#github-repo-zip]: https://www.overleaf.com/docs?snip_uri=https://github.com/k4rtik/latex-project-report-template/archive/refs/heads/master.zip

In case you want to use this badge for any github repository, all you need to do is:

REPLACE the following:

[#github-repo-zip]: https://www.overleaf.com/docs?snip_uri=https://github.com/k4rtik/latex-project-report-template/archive/refs/heads/master.zip

WITH this:

[#github-repo-zip]: https://www.overleaf.com/docs?snip_uri=https://github.com/<OWNER>/<REPO>/archive/refs/heads/<BRANCH>.zip

So, finally, your modified markdown code for overleaf-badge would look like this:

  • <REPO>: repository name
  • <OWNER>: owner of repository
  • <BRANCH>: branch name under the repository
[![Open in Overleaf][#overleaf-badge]][#github-repo-zip]

[#overleaf-badge]: https://tinyurl.com/overleaf-badge
[#github-repo-zip]: https://www.overleaf.com/docs?snip_uri=https://github.com/<OWNER>/<REPO>/archive/refs/heads/<BRANCH>.zip
@sugatoray
Copy link
Author

Example image of overleaf-badge.

overleaf-badge-image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment