Install a TeX distribution, set TeXstudio's build command and enable SyncTeX. Follow the setup below to compile a first PDF and fix common errors.
Install a TeX distribution and TeXstudio
Install a TeX distribution first: TeX Live on Linux or Windows, MacTeX on macOS, or MiKTeX where supported. Then install TeXstudio from its official download page. TeXstudio calls programs such as pdflatex and latexmk from that distribution; if it cannot find them, check their paths in the Commands settings. TeXstudio began as TexMakerX, a fork of Texmaker, and was renamed at version 2.2.
First build: compiler, PDF viewer and SyncTeX
Open Options → Configure TeXstudio (Preferences on macOS). Set the compiler and PDF viewer in Build; use Commands to edit the executable path and options. Start with a small .tex file before opening an existing project.
- In Build, choose pdfLaTeX as Default Compiler for a simple Latin-script document, or LuaLaTeX when the document requires it. Use latexmk if it is installed and you want it to manage repeated runs.
- Choose Compile & View for Build & View, with the internal PDF viewer. In Commands, ensure the selected compiler includes
-synctex=1and-file-line-error. - Save a minimal document as
hello.tex, then run Build & View (F5). Confirm that the log names the intended engine and the PDF opens. - Ctrl-click a word in the source to jump to the PDF, and Ctrl-click the PDF to return to the source. If either jump fails, check the
.synctex.gzfile and the internal viewer.
% !TeX program = pdflatex
\documentclass{article}
\begin{document}
Hello, TeXstudio.
\end{document}The Build tab and the Commands tab: reading txs:///
Open Options → Configure TeXstudio (Preferences on macOS). Set the compiler and PDF viewer in Build; use Commands to edit the executable path and options. Start with a small .tex file before opening an existing project.
Day to day you touch only four actions. Build & View (F5) compiles and then opens the PDF; Compile (F6) only produces it; View (F7) opens what is already there; and Clean sweeps away the intermediates — .aux, .toc and their relatives — while leaving the finished PDF alone.
A meta command is just a list of names that begin with txs:///, joined by the pipe |. “Build & View” is, in essence, a two-word expression meaning “the default compiler, then the default viewer.” Every command registered in the Commands tab can be referenced the same way, so you can splice your own conversion step into the chain.
| Name | What it is | Where you meet it |
|---|---|---|
txs:///quick | the build-then-preview chain | Build & View (F5) |
txs:///compile | the default compiler (pdfLaTeX out of the box) | Compile (F6) |
txs:///view | the default viewer | View (F7) |
txs:///pdflatex | the pdflatex line of the Commands tab itself | can be named as the default compiler |
txs:///latex | the latex line, which produces a DVI | used by the chains that go via DVI |
txs:///view-pdf | the line that opens a PDF, internal viewer or external | keep it internal if you want SyncTeX |
Out of the box the default compiler is pdfLaTeX, but switching it to latexmk is the standard move. latexmk inspects the dependencies and reruns exactly as often as the bibliography, the index and the cross-references demand, so no human has to count passes. Write it in the Commands tab like this. Note that % expands to the absolute path of the root (master) document without its extension — the root, not the file you happen to be editing. That single detail is what makes multi-file projects behave.
latexmk -pdf -synctex=1 -interaction=nonstopmode -file-line-error %.texTo change engines per document, a magic comment on the first line does it. TeXstudio reads % !TeX program, % !TeX root, % !TeX encoding and % !TeX spellcheck, among others. Put the line below at the top and that document alone compiles with LuaLaTeX, with the settings dialog left untouched. The exact syntax of the % !TEX family is covered in detail on the TeXShop page.
% !TeX program = lualatex
% !TeX root = ../thesis.tex
% !TeX spellcheck = en_GBConfiguring builds for Japanese
Two routes are in wide use. One is LuaLaTeX: in the Build tab set Build & View to “Compile & View” and the default compiler to “LuaLaTeX,” and one press of F5 takes you to the PDF. For a fresh start this is the straightforward choice. The other is upLaTeX + dvipdfmx, long the Japanese standard; because it puts a DVI before the PDF, you set Build & View to the “DVI->PDF chain” and the default compiler to “LaTeX.”
The clearest arrangement is to describe the engine combination in a .latexmkrc and let TeXstudio merely call latexmk. Put the following file next to your .tex and latexmk handles the upLaTeX → dvipdfmx flow, the bibliography (upbibtex), the index (upmendex) and the number of reruns. Because $latex carries -synctex=1, SyncTeX keeps working too.
$latex = 'uplatex %O -synctex=1 -interaction=nonstopmode %S';
$bibtex = 'upbibtex %O %B';
$makeindex = 'upmendex %O -o %D %S';
$dvipdf = 'dvipdfmx %O -o %D %S';
$pdf_mode = 3;$pdf_mode = 3 selects the mode “make a DVI, then turn it into a PDF with $dvipdf.” The tokens %O (extra options), %S (the source file), %B (the base name without extension) and %D (the output target) are latexmk's placeholders, and are not the same thing as TeXstudio's %. Set up this way, you get the same result whether the build is started from TeXstudio, from the command line, or from another editor entirely — because the configuration lives in one place.
Read the log from the first error
Before changing settings at random, look at two things: which command was launched, and what the first error in the log is. LaTeX errors cascade, so the first red line has usually produced all the ones after it. TeXstudio's log panel is built for exactly this reading order: you can switch between the raw log and a table that sorts the messages into errors (red), warnings (yellow) and overfull boxes (blue). Move between errors with Ctrl+Shift+↑ and Ctrl+Shift+↓, and between warnings and boxes with Alt+Shift+↑ and Alt+Shift+↓.
- If you see
Could not start the command, the suspect is PATH and the state of your TeX Live / MiKTeX installation, not TeXstudio. Check the executable path in the Commands tab. File not foundmeans one of three things: the root file, a relative path, or a figure filename — and check whether the extension is written out.- When a package is missing, install it with
tlmgr installon TeX Live or MiKTeX Console on MiKTeX. The editor cannot fix this one. - Click the line number in the log, fix only the first error, rebuild, and then read on. Reading the far end of a cascade first is usually wasted time.
Why completion knows your \labels: the .cwl files
TeXstudio is not interpreting LaTeX. It is reading .cwl files — completion word lists. The format came originally from another LaTeX editor, Kile, and TeXstudio extended it with semantic information: this argument is a label, that spot is where the cursor should land. That is why typing \ref{ offers the labels in your document and \cite{ offers the bibliography keys (bibIDs). When you \usepackage something, the matching cwl is loaded if one exists; if not, TeXstudio generates one from the .sty automatically — which yields command names but no sense of what the arguments mean. For a package of your own, writing \usepackage{./myPackage} with a relative path makes TeXstudio look for ./myPackage.cwl.
Three more keystroke-savers are worth learning. When the candidates share a leading string, pressing Tab fills in that common part at once. Begin an environment — type \begin{itemize} — and the matching \end{itemize} is inserted for you. And resting the cursor on an environment name for a moment brings up a mirror cursor, letting you rewrite the names in \begin and \end simultaneously — turning itemize into enumerate in one move. To close whatever environment or brace is still open, press Alt+Return. Forgetting to close something is among the commonest LaTeX accidents, so that one is worth committing to memory.
The structure view, and checking spelling and grammar as you type
The Structure view on the left becomes a map of the document. It lists headings (\section and its family), labels (\label), the files pulled in by \input and \include, beamer blocks, and TODOs — both the \todo{} command and % TODO / %todo comments are picked up. Click an entry and you land there. In a long manuscript or a multi-file project, this list is what keeps you from losing track of where you are.
Spell checking runs while you type, and right-clicking a suspect word offers corrections. The dictionaries are in hunspell format — the same machinery LibreOffice and Firefox use, so extra dictionaries can be borrowed from there. To pin the language to a file, write % !TeX spellcheck = de_DE on the first line and that file switches language automatically every time it is opened. It earns its keep when you are editing a multilingual volume.
Grammar checking, on the other hand, is not TeXstudio's own judgement. The open-source proofreading engine LanguageTool runs locally as a server, TeXstudio connects to it at startup, and each finished paragraph is sent over and the findings come back (you point it at the server URL and the jar under Options → Configure TeXstudio → Language Checking). Because of that arrangement your prose never leaves the machine — a comfort when the manuscript is not yet published.
SyncTeX: ctrl-click, forwards and backwards
There are only two conditions. First, pass -synctex=1 to the compile command. SyncTeX is a feature of the TeX engine rather than of the editor, and this switch is what makes it write the synchronisation file .synctex.gz (the latexmk line and the .latexmkrc above already carry it; if you forget, TeXstudio offers to correct the command for you). Second, open the PDF in the internal viewer. It is that viewer's SyncTeX support that makes the two-way jumps possible.
The gestures are easy to remember, because both directions are Ctrl + left-click. Do it in the source and you land at the matching place in the PDF (forward search); do it in the PDF and you land on the matching source line (inverse search). The right-click menu offers the same under “Go To PDF” and “jump to source.” Forward search also runs automatically to your current cursor position each time the viewer opens. Enable “scrolling follows cursor” and “cursor follows scrolling” and the two stay linked continuously as you write, which makes the proofreading question “which line produced this paragraph?” simply disappear.