Demo (I'm pressing Ctrl-S
to save and render PDF):
Latex.Workshop.Demo.mp4
Instructions by ChatGPT below:
- Install Visual Studio Code: Download and install VS Code from here.
- Install Git: Download and install Git from here.
- Install LaTeX Distribution: Install a LaTeX distribution like TeX Live (for Linux/Mac) or MikTeX (for Windows).
- Install latexmk:
- Open a terminal and run:
sudo apt install latexmk
- Open a terminal and run:
-
LaTeX Workshop: This extension provides rich support for LaTeX in VS Code.
- Open VS Code.
- Go to Extensions (
Ctrl+Shift+X
). - Search for
LaTeX Workshop
and install it.
-
GitLens: This extension enhances Git capabilities in VS Code.
- In the Extensions pane, search for
GitLens
and install it.
- In the Extensions pane, search for
-
Live Share (Optional): For real-time collaboration.
- In the Extensions pane, search for
Live Share
and install it.
- In the Extensions pane, search for
- Open VS Code.
- Open Terminal in VS Code (
Ctrl+
). - Clone Your Repository:
git clone https://github.com/your-username/your-repo.git
- Open the Cloned Folder:
- Go to
File > Open Folder...
and select the cloned repository folder.
- Go to
- Configure LaTeX Workshop:
- Open the command palette (
Ctrl+Shift+P
). - Search for and select
Preferences: Open Settings (JSON)
. - Add the following configuration for LaTeX Workshop:
{ "latex-workshop.latex.tools": [ { "name": "pdflatex", "command": "pdflatex", "args": [ "-synctex=1", "-interaction=nonstopmode", "-file-line-error", "%DOC%" ] }, { "name": "bibtex", "command": "bibtex", "args": [ "%DOCFILE%" ] }, { "name": "latexmk", "command": "latexmk", "args": [ "-synctex=1", "-interaction=nonstopmode", "-file-line-error", "-pdf", "-outdir=build", "%DOC%" ] } ], "latex-workshop.latex.recipes": [ { "name": "latexmk", "tools": [ "latexmk" ] }, { "name": "pdflatex -> bibtex -> pdflatex*2", "tools": [ "pdflatex", "bibtex", "pdflatex", "pdflatex" ] } ], "latex-workshop.view.pdf.viewer": "tab", "latex-workshop.latex.autoBuild.run": "onFileChange", "latex-workshop.latex.clean.enabled": true, "latex-workshop.latex.outDir": "build", "latex-workshop.view.pdf.external.viewer.command": "xdg-open", "latex-workshop.view.pdf.external.viewer.args": [ "%PDF%" ], "latex-workshop.view.pdf.external.viewer.enabled": true }
- Open the command palette (
-
Create a New LaTeX File:
- Go to
File > New File
and save it with a.tex
extension (e.g.,main.tex
). - Write your LaTeX code in this file.
- Go to
-
Build the LaTeX Document:
- Save your
.tex
file (Ctrl+S
). - LaTeX Workshop will automatically build the document if
autoBuild.run
is set toonFileChange
. - To manually build, open the command palette (
Ctrl+Shift+P
), search forLaTeX Workshop: Build with recipe
, and select your desired recipe.
- Save your
-
View the PDF:
- LaTeX Workshop should now open the
build/main.pdf
file in a new tab within VS Code. If you want to open it with an external viewer, ensure that theexternal.viewer.enabled
setting is true.
- LaTeX Workshop should now open the
-
Stage Changes:
- Open the Source Control pane (
Ctrl+Shift+G
). - Stage your changes by clicking the
+
icon next to the file.
- Open the Source Control pane (
-
Commit Changes:
- Enter a commit message in the message box and click the
✔
icon to commit.
- Enter a commit message in the message box and click the
-
Push Changes:
- Push your changes to the remote repository using the push button in the Source Control pane.
-
Pull Changes:
- To update your local repository with changes from the remote repository, use the pull button in the Source Control pane.
-
Handle Merge Conflicts:
- If there are merge conflicts, VS Code will highlight them, allowing you to resolve them directly.
-
Real-time Collaboration (Optional):
- Use the Live Share extension to collaborate in real-time with others.
- Set Up Continuous Integration:
- Use a service like GitHub Actions to automatically build your LaTeX documents when changes are pushed to the repository.
- Create a
.github/workflows/latex.yml
file in your repository with the following content:name: Build LaTeX document on: [push] jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: Set up TeX Live uses: xu-cheng/latex-action@v2 - name: Compile LaTeX document run: latexmk -pdf -file-line-error -interaction=nonstopmode -outdir=build main.tex
By following these steps, your LaTeX build should output the PDF to the /build
directory, and LaTeX Workshop should link to build/main.pdf
correctly. If you still encounter issues, please ensure that the directory structure and file paths are correct and that there are no typos in the configuration.
I changed to iclr template and got this error:
! LaTeX Error: File eso-pic.sty' not found.
The error message indicates that the eso-pic.sty
package is missing from your LaTeX installation. This package is required by the ICLR template you're using.
To resolve this, you need to install the missing package. On a Debian-based system (such as Ubuntu), you can install the necessary LaTeX package using the following command:
sudo apt-get install texlive-latex-extra
This package includes eso-pic.sty
and many other common LaTeX packages that are often required.
-
Install the Required Package: Open a terminal and run:
sudo apt-get install texlive-latex-extra
-
Ensure Your LaTeX Setup is Correct: Make sure your LaTeX Workshop configuration in VS Code is set to build the documents correctly and that the output directory is specified as
/build
. -
Retry Compiling Your Document: Open your LaTeX file in VS Code and try building it again.
Ensure that your VS Code settings are still correctly configured as mentioned before:
{
"latex-workshop.latex.tools": [
{
"name": "pdflatex",
"command": "pdflatex",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"%DOC%"
]
},
{
"name": "bibtex",
"command": "bibtex",
"args": [
"%DOCFILE%"
]
},
{
"name": "latexmk",
"command": "latexmk",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"-pdf",
"-outdir=build",
"%DOC%"
]
}
],
"latex-workshop.latex.recipes": [
{
"name": "latexmk",
"tools": [
"latexmk"
]
},
{
"name": "pdflatex -> bibtex -> pdflatex*2",
"tools": [
"pdflatex",
"bibtex",
"pdflatex",
"pdflatex"
]
}
],
"latex-workshop.view.pdf.viewer": "tab",
"latex-workshop.latex.autoBuild.run": "onFileChange",
"latex-workshop.latex.clean.enabled": true,
"latex-workshop.latex.outDir": "build",
"latex-workshop.view.pdf.external.viewer.command": "xdg-open",
"latex-workshop.view.pdf.external.viewer.args": [
"%PDF%"
],
"latex-workshop.view.pdf.external.viewer.enabled": true
}
After installing the texlive-latex-extra
package, try building your LaTeX document again. This should resolve the eso-pic.sty
not found error and allow you to generate the PDF output in the /build
directory.