TeXstudio - User Manual
TeXstudio - User Manual
TeXstudio - User Manual
1 of 29
http://texstudio.sourceforge.net/manual/current/usermanual_en.html
1. Configuring TeXstudio
Before using TeXstudio, you should configure the editor and latex related commands via the "Configure TeXstudio" command in the "Options" menu ("Preferences" under Mac OS X). Note that there
are two levels of detail. More advanced or less often used options are only visible if you toggle "Show advanced options" in the lower left corner.
09/12/2015 10:33 PM
2 of 29
http://texstudio.sourceforge.net/manual/current/usermanual_en.html
? followed by further characters See the instruction at the bottom of the configuration dialog.
[txs-app-dir]
[txs-settings-dir]
The section Forward/Inverse search gives some example commands for common viewers.
You can always restore the original settings using the revert button to the right.
09/12/2015 10:33 PM
3 of 29
http://texstudio.sourceforge.net/manual/current/usermanual_en.html
09/12/2015 10:33 PM
4 of 29
http://texstudio.sourceforge.net/manual/current/usermanual_en.html
User commands can be defined here by "adding" them. Each user command has a name with a pattern <command id>:<display name>, e.g. user0:User Command 0. The command id has to be
unique and must not contain spaces. In advanced mode, you can reference it using txs:///"<command id>. The display name will be shown in the tools menu. The user commands can be activated
either by short cut (alt+shift+F%n) or by the tools menu (Tools/User).
User commands can either consist of a combination of known commands by selecting them from a list of available commands. This is triggered by clicking the spanner-symbol.
Alternatively a command can be directly selected through the file system.
txs:///view-log
txs:///conditionally-recompile-bibliography Checks if the bib files have been modified, and calls txs:///recompile-bibliography, iff that is the case
The internal pdf viewer also accepts the following options (txs:///internal-pdf-viewer) to modify its behaviour:
--embedded
--windowed
--close(all|windowed|embedded)
--preserve-existing
Does not change any existing viewers (i.e. always opens a new one)
--preserve(embedded|windowed)
--preserve-duplicates
--(no-)auto-close
Determines whether the viewer should be closed, when the corresponding tex file is closed (default: auto-close iff embedded)
--(no-)focus
Determines whether the viewer should be focused (default: focus iff windowed)
--(no-)foreground
filename
Determines the file to open. Like in other commands, file patterns are supported. If this parameter is not provided, TXS uses "?am.pdf", i.e. the absolute path
of the main file. If the parameter is not an absolute filename, it is searched for in the directory of the main file as well as in Options -> Build -> Build
Options -> Additional Serach Paths -> PDF Files
It is also possible to modify the arguments of called subcommands with argument modifiers or by adding a new argument . These modifiers are passed through called lists, so it will always change
the arguments of the finally called program, even if the directly called subcommand is just a wrapper around another command:
txs:///foobar --xyz
txs:///foobar[--xyz=123] This will change the value of the xyz option to 123 (i.e. removing any xyz option defined in foobar)
txs:///foobar{--xyz=123} This will remove --xyz=123 from the foobar command line, ignoring xyz options with other values
txs:///foobar{--xyz}
This will remove any --xyz option from the foobar command line, regardless of its value
txs:///foobar{}
This will remove all options from the foobar command line, leaving only the name of the executable
Finally, there are also hidden options, which can only be changed by modifing the ini-file: Tools/Kind/LaTeX, Tools/Kind/Rerunnable, Tools/Kind/Pdf, Tools/Kind/Stdout, Tools/Kind/Viewer, which
give a list of commands that are treated as latex compiler (e.g. show the log afterwards), rerunnable (repeat command call, if there are warnings), pdf generators (e.g. pdflatex), commands that
prints to stdout (e.g. bibtex), and viewers (e.g. only open once).
Environment Variables
The environment variables available within the execution are the same as the ones that are available in the context in which TeXstudio was started. In particular this is true for the PATH. On
Linux/OS X the PATH may depend on the way you started TeXstudio. Programs started from the GUI may have a different PATH setting than programs started from a shell (because some variables
may only defined in the context of a shell (e.g. via ~/.bashrc).
By default, TeXstudio parses environment variables in your commands. The syntax is adapted to the according operating system. A variable MYVAR would be written as %MYVAR% on Windows and
09/12/2015 10:33 PM
5 of 29
http://texstudio.sourceforge.net/manual/current/usermanual_en.html
$MYVAR on Linux and OS X. Windows environment variables are case-insensitive, whereas they are case-sensitive on Linux and OS X. Parsing of environment variables can be deactivated in the Build
section of the options.
Working Directory
The working directory is set to the path of root document.
Shell Functionality
All commands specified in the configuration (i.e. Commands and User Commands) are executed directly. There is no shell involved. So most shell functionality does not work.
Output Redirection
TeXstudio provides limited output redirection capabilities. You can only output to the message panel (> txs:///messages) or suppress output (> /dev/null). The default setting depends on the
command. The same targets are allowed for stderr: 2> txs:///messages, 2> /dev/null. Additionally, you can redirect to the same target as stdout by using 2>&1.
A typical usecase would be to suppress all output of a command: >/dev/null 2>&1
Note: Instead of the Linux/Unix notation > /dev/null, you may alternatively use the Windows notation > nul. Because these commands are directly interpreted by TXS, both variants work on all
operating systems.
or on Windows:
cmd /C "/path/to/testscript.bat foo > bar"
09/12/2015 10:33 PM
6 of 29
http://texstudio.sourceforge.net/manual/current/usermanual_en.html
To make life easy TeXstudio lets you choose a preferred language for the spell checker. However, if you frequently work with files in different languages you may want to override the default
behavior. This can be done in two ways. First you can specify the language of the file via the language menu in the status line. This setting will be lost as soon as the file is closed. To permanently
save the language of the file TeXstudio supports a special "magic comment" % !TeX spellcheck = de_DE. If this comment is present in a file, its language is automatically set when the file is
loaded.
Please note: spell checking with Ctrl+Shift+F7 starts at the cursor position and not at the beginning of the document.
If the interactive spell checker is enabled (default), any incorrectly spelled word is underlined with a red wave. Right-click on the word to open a menu with a list of possible corrections. In this
context menu you can also add the word to the ignore list. If your dictionary is very large (> 5MB), opening the context menu and showing possible suggestions can take some seconds. If you don't
need the suggestion, you can press shift while right clicking and don't have to wait.
Since the internal structure of the dictionaries is complex (e.g. contains rules how to generate a word with in different inflections) it is not possible to simply add words to the dictionary. Instead if
a word is missing in the dictionary, you can add it to an ignore list, so that the spell checker won't complain about it. The ignore list is normally saved in the same directory as the dictionary. It's a
plain text file with the extension .ign. If this isn't possible (e.g. missing access rights) the list is stored in the user configuration directory.
09/12/2015 10:33 PM
7 of 29
http://texstudio.sourceforge.net/manual/current/usermanual_en.html
09/12/2015 10:33 PM
8 of 29
http://texstudio.sourceforge.net/manual/current/usermanual_en.html
09/12/2015 10:33 PM
9 of 29
http://texstudio.sourceforge.net/manual/current/usermanual_en.html
09/12/2015 10:33 PM
10 of 29
http://texstudio.sourceforge.net/manual/current/usermanual_en.html
09/12/2015 10:33 PM
11 of 29
http://texstudio.sourceforge.net/manual/current/usermanual_en.html
This dialog allows you to set the main features of your document (class, paper size, encoding...).
Note : You can add other options by clicking the "+" buttons. All your settings are recorded.
You can also type your own preamble model in the editor : with the "Copy/paste" or "Save As" commands, you can use it for a new document.
You can either create a new editor document from the template or create it as file(s) on disk and open these in the editor. The former option is not available for multi-file templates.
New templates can be created by using the command "File/Make Template" on a opened document which you like to have has a template. Note that this dialog currently does not support the full
capabilities of the template system. In particular you cannot supply a preview image or create a multi-file template with it. You'll have to do this manually (see the template format).
User added templates can be edited or deleted by using the context menu in the template selection dialogue. Built-in templates can not be changed.
User templates are saved in the /templates/user/ subdirectory of the config directory.
:
:
:
:
:
:
:
"Book",
"TXS built-in",
"04.01.2013",
"1.1",
"Default LaTeX class for books using separate files for each chapter.",
"Public Domain",
"./TeX_files/chapter01.tex;main.tex"
09/12/2015 10:33 PM
12 of 29
http://texstudio.sourceforge.net/manual/current/usermanual_en.html
FilesToOpen only has an effect for mutli-file documents. You may add a preview image next to the template file. Again, it must have the same name, but extension ".png".
The "Structure View" is automatically updated as you type. You can also use the "Refresh Structure" (menu "Idefix") command at any moment.
The structure view shows labels, sections, includes and beamer blocks and todos.
There are two kind of todos that will be listed a) todos from a todo-like command, e.g. \todo{} from the package todonotes. b) todo-like comments: This is a comment with a capitalized first word,
e.g. "% TODO", "%FIXME", "%ASK".
The structure view also offers a context menu which allows one to copy/cut all text which belongs to a section (including subsection) and paste it before or after a section. Section can be
indented/unindented which means that the hierarchy level is changed by one, i.e. \section is changed to \subsection, and all subsections are treated accordingly
For each file, three bookmarks can be used to speed up navigation : just click on a line number to add or remove a bookmark. When you have already defined three bookmarks, you must remove
one of them to add a new bookmark. To jump to the line corresponding to a bookmark in the editor, just click on the buttons in the status bar.
Additional option: a selected text can be directly framed by certain environments. Example: while clicking on the button "Bold" after having selected the word "Hello" , you will obtain the code:
\textbf{Hello}.
This option is available for all the environments indicated by "[selection]" in the "LaTeX" menu.
Capitalisation
The menu "Edit" -> "Text Operations" contains a few methods for changing the capitalization of selected text:
To
To
To
To
Lowercase
Uppercase
Titlecase (strict)
Titlecase (smart)
Both variants of "To Titlecase" leave small words like a, the, of etc. in lowercase. Additionally, "To Titlecase (smart)" does not convert any words containing capital letters, assuming they are
acronymes which require a fixed capitalization (e.g. "TeXstudio").
2.6 Spacings
The usual "spacing" commands are available in the "LaTeX" and "Math" menus.
09/12/2015 10:33 PM
13 of 29
http://texstudio.sourceforge.net/manual/current/usermanual_en.html
09/12/2015 10:33 PM
14 of 29
http://texstudio.sourceforge.net/manual/current/usermanual_en.html
Additional option:for the \ref command, a dialog box allows you to select directly the label.
With the "symbols panels" in the structure view, you can insert the code of 400 mathematical symbols.
09/12/2015 10:33 PM
15 of 29
http://texstudio.sourceforge.net/manual/current/usermanual_en.html
You can also define the format of your mathematical text via the "Math" menu.
For the "array" environments, a wizard (like the "Tabular" wizard) is available in the "Wizard" menu. With this wizard, you can select the environment : array, matrix, pmatrix.... The cells can be
directly completed.
2.14 Thesaurus
TeXstudio has integrated a simple thesaurus. OpenOffice 2.x databases are used for this. By placing the cursor on a word and activating the thesaurus (Ctrl+Shift+F8 or Edit/Thesaurus), it tries to
find synonyms for this word. Please be patient if you start the thesaurus at first time since loading the database just occurs then and can take a few moments.
The first line to the left contains the word, for which a synonym is searched for. The list below gives a list of word classes. The can be chosen to reduce the number of suggestions. The column to
the right contains the list of suggested synonyms. A selected word from this list apears in the first line to the right as proposition for replacement of the text. This word can be changed manually. It
09/12/2015 10:33 PM
16 of 29
http://texstudio.sourceforge.net/manual/current/usermanual_en.html
is also used to do further investigations for words and their synonyms which "start with" or "contain" that word. With "lookup" it can be directly used to look for a synonym for that word.
Delete word/command/environment
With the shortcut Alt+Del, the word under the cursor is deleted. If it is a command, the command is deleted including opening and closing braces. E.g. "\textbf{text}" leave "text". If it is an
environment, the enclosing bengin/end are removed.
Rename environment
If you place the cursor on an environment name or the corresponding begin- or end-command, after a moment a mirror-cursor is activated on the environment name which allows synchronous
change of the environment name in the begin- and end-command. So if you want to change a "\begin{tabular}...\end{tabular}" construction to "\begin{tabularx}...\end{tabularx}", place the text
cursor on "tabular", wait for a second and then, after the mirror-cursor appears, change "tabular" to "tabularx".
Cut Buffer
If you select something and then start to type in a command and complete it, the selection is put in as first argument. E.g. you have a "text", select it and start typing "\textbf", command which is
completed. The resulting text is "\textbf{text}"
3. Compiling a document
3.1 Compiling
The easiest way to compile a document is to use the "Compile" command or the "Build&View" command ("Compile" button - shortcut : F6). You can select the default command via the "Configure
TeXstudio" dialog.
(You can also launch each command one by one in the "Tools" menu).
Note : the "Clean" command in the "Tools menu" allows you to erase the files (dvi, toc, aux...) generated by a LaTeX compilation (except the ps and pdf files).
Warning : all your files must have an extension and you can't compile an "untitled" file or a file with a space in his name.
The "Next Latex Error"and "Previous LaTeX Error" commands allow to get to the errors detected during compilation.
Lines with errors, warnings, bad boxes will be highlighted with red, yellow or blue background and you can jump between them using Ctrl+Up/Down. (Ctrl+Shift for errors only, Ctrl+Alt for warnings
only, Alt+Shift for bad boxes only)
A tool tip will show more details of the mistake if you jump to a line (it is also shown if you move the mouse over the mark left from the line numbers).
4. Other features
4.1 About documents separated in several files
LaTeX documents may be spread over multiple files. TeXstudio automatically understands parent/child relations of loaded documents. This includes the detection of the root document and
knowledge on defined labels and commands.
09/12/2015 10:33 PM
17 of 29
http://texstudio.sourceforge.net/manual/current/usermanual_en.html
4.3 Bibliography
For the "bib" files , the "Bibliography" menu enables you to directly insert the entries corresponding to the standard types of document.
Note: the optional fields can be automatically deleted with the "Clean" command of the "Bibliography" menu.
09/12/2015 10:33 PM
18 of 29
http://texstudio.sourceforge.net/manual/current/usermanual_en.html
Description
Global scope
confirm(str) or confirmWarning(str)
debug(str)
writeFile(name, value)
readFile(name)
system(cmd)
setGlobal(name, value)
getGlobal(name)
hasGlobal(name)
setPersistent(name, value)
Sets a global configuration variable. (can change the values of the ini file, requires write privileges)
getPersistent(name)
Reads a global configuration variable. (can read all values of the ini file, requires read privileges)
hasPersistent(name)
hasReadPrivileges()
hasWritePrivileges()
registerAsBackgroundScript([id])
Allows the script to run in the background (necessary iff the script should handle events/signals)
triggerMatches
Matches of the regular trigger expression, if the script was called by an editor trigger.
triggerId
include(script)
pdfs
searchFor is the text which is searched. It can be either a string (e.g. "..") or a regexp (e.g. /[.]{2}/).
options is a string and a combination of "i", "g", "w" to specify a case-insensitive search, a global search (continue
after the first match) or a whole-word-only search.
scope is a cursor constraining the search scope (see editor.document().cursor).
callback is a function which is called for every match. A cursor describing the position of the match is passed as
first argument.
All arguments except searchFor are optional, and the order may be changed (which may not be future compatible). The
function returns the number of found matches.
This function searches and replaces something in the editor. It behaves like editor.search apart from the replaceWith
argument which can be a simple string or a callback function. If it is a function the return value of replaceWith is used to
replace the match described by the cursor passed to replaceWith.
This function replaces the current selections with newText or inserts newText, if nothing is selected.
If newText is a function, it will be called with the selected text and corresponding cursor, and the return value will be
the newText.
It is recommended to use this function for all text replacements/insertions, since it is the easiest way to handle multiple
cursors/block selections correctly. Though it is only available in txs >= 2.8.5.
Options is an object that can have the following properties:
editor.replaceSelectedText(newText, [options])
{"noEmpty": true} only replaces; does not insert anything if the selection is empty
{"onlyEmpty": true} only inserts at the cursor position; does not change non empty selected text
{"append": true} appends newText to the current selection, does not remove the old text
{"prepend": true} prepends newText to the current selection, does not remove the old text
{"macro": true} Treats newText as normal macro text, e.g. inserting %< %> placeholders
Examples:
09/12/2015 10:33 PM
19 of 29
http://texstudio.sourceforge.net/manual/current/usermanual_en.html
editor.undo();
editor.redo();
editor.cut();
editor.copy();
editor.paste();
editor.selectAll();
select all
editor.selectNothing();
editor.find();
editor.findNext();
find next
editor.replacePanel();
editor.gotoLine();
editor.indentSelection();
indent selection
editor.unindentSelection();
unindent selection
editor.commentSelection();
comment selection
editor.uncommentSelection();
uncomment selection
editor.clearPlaceHolders();
editor.nextPlaceHolder();
editor.previousPlaceHolder()
set Placeholder
editor.setFileName(f);
set filename to f
editor.write(str)
inserts str at the current cursors position (if there are cursor mirrors, str will be inserted by all of them)
editor.insertText(str)
inserts str at the current cursor position (cursor mirrors are ignored, so it is preferable to use replaceSelectedText or
write instead)
editor.setText(text)
editor.text()
editor.text(int line)
editor.document().lineCount()
Document object
editor.document().visualLineCount()
Returns a cursor object. If lineTo is given the cursor has a selection from line:column to lineTo:columnTo, otherwise not.
editor.document().text([removeTrailing = false], [preserveIndent = true]) Returns the complete text of the document
editor.document().textLines()
editor.document().lineEndingString()
editor.document().canUndo()
editor.document().canRedo()
editor.document().expand(lineNr)
editor.document().collapse(lineNr)
editor.document().expandParents(lineNr)
editor.document().getMasterDocument();
editor.document().getTopMasterDocument();
editor.document().getRootDocument();
Returns the open document which indireclty includes this document and is not itself included by any other document
editor.document().getMagicComment(name);
editor.document().getLastEnvName(lineNr)
Returns the name of the current enviroment (at the end of the line).
documentManager.currentDocument
Current document (usually the same as editor.document(), unless the script is running in background mode)
Master document
[documentManager.]documents
documentManager.findDocument(fileName)
documentManager.singleMode()
documentManager.getMasterDocumentForDoc(document)
documentManager.getRootDocumentForDoc(document)
Returns the open document (possibly indirectly) including the given document
documentManager.findFileFromBibId(id)
Returns the file name of the bib file containing an entry with the given id
cursor.atEnd()
Cursor object
cursor.atStart()
cursor.atBlockEnd()
cursor.atBlockStart()
cursor.atLineEnd()
cursor.atLineStart()
cursor.hasSelection()
cursor.lineNumber()
cursor.columnNumber()
cursor.anchorLineNumber()
cursor.anchorColumnNumber()
cursor.shift(int offset)
set the cursor position after pos-characters counted from document start (very slow)
09/12/2015 10:33 PM
20 of 29
http://texstudio.sourceforge.net/manual/current/usermanual_en.html
cursorEnums.Up
cursorEnums.Down
cursorEnums.Left
cursorEnums.PreviousCharacter = Left
cursorEnums.Right
cursorEnums.NextCharacter = Right
cursorEnums.Start
cursorEnums.StartOfLine
cursorEnums.StartOfBlock = StartOfLine
cursorEnums.StartOfWord
cursorEnums.StartOfWordOrCommand
cursorEnums.PreviousBlock
cursorEnums.PreviousLine = PreviousBlock
cursorEnums.PreviousWord
cursorEnums.WordLeft
cursorEnums.WordRight
cursorEnums.End
cursorEnums.EndOfLine
cursorEnums.EndOfBlock = EndOfLine
cursorEnums.EndOfWord
cursorEnums.EndOfWordOrCommand
cursorEnums.NextWord
cursorEnums.NextBlock
cursorEnums.NextLine = NextBlock
Options for MoveMode are:
cursorEnums.MoveAnchor
cursorEnums.KeepAnchor
cursorEnums.ThroughWrap
cursor.moveTo(int line, int column);
cursor.eraseLine();
insert text text at cursor (this function will ignore indentations and mirrors, see editor.write and editor.insertText)
cursor.selectedText()
cursor.clearSelection();
clears selection
cursor.removeSelectedText();
cursor.replaceSelectedText(text);
cursor.deleteChar();
cursor.deletePreviousChar();
cursor.beginEditBlock();
begins a new edit block. All cursor operations encapsulated in an edit block are undone/redone at once.
cursor.endEditBlock();
app.getVersion()
App object
app.clipboard
app.getCurrentFileName()
app.load(file)
Loads an file
app.fileOpen/Save/Close/.../editUndo/.../QuickBuild/...
All menu commands (i.e. all slots in the texmaker.h file). You can view a list of all currently existing slots on the "menu"
page of the config dialog.
app.getManagedMenu(id)
app.getManagedAction([id])
Returns an QAction with a certain id (all ids have the form main/menu1/menu2/.../menuN/action, with usually one
menu, e.g. "main/edit/undo", see texmaker.cpp)
app.createUI(file, [parent])
app.createUIFromString(string, [parent])
app.slowOperationStarted()/slowOperationEnded()
Notify txs about the start/end of a slow operation to temporary disable the endless loop detection.
app.simulateKeyPress(shortcut)
Trigger a KeyPress event for the given shortcut, e.g. app.simulateKeyPress("Shift+Up"). Note: this is mainly
intended for shortcuts and navigation. Currently, it does not support all functions of a KeyPress event. In particular, you
cannot type any text.
new UniversalInputDialog()
Adds a new variable with the given default value, optional description and id to the dialog; and returns the corresponding
qt component.
A string default value becomes a QLineEdit, a number a QSpinBox and an array a QComboBox.
dialog.get(nr/id)
Returns the current value of the nr-th added variable or the variable with a certain id.
dialog.getAll()
Returns the value of all variables as combined numerical/associative array. You can use returnvalue[i] to get the i-th
variable, and returnvalue.id to get the variable with a certain id.
dialog.exec()
Displays the dialog. Returns 1 if the user accepted the dialog, 0 if it was canceled.
dialog.show()
Short form: Creates a new dialog, adds all variables of the array and call exec on it.
fileChooser.exec()
fileChooser.setDir(dir)
UniversalInputDialog class
FileChooser object
fileChooser.setFilter(filter)
fileChooser.fileName()
09/12/2015 10:33 PM
21 of 29
http://texstudio.sourceforge.net/manual/current/usermanual_en.html
Some examples:
Copy current file name to clipboard:
%SCRIPT
app.clipboard = editor.fileName();
app.fileNew();
newEditor = documentManager.currentDocument.editorView.editor;
for (var prop in obj)
newEditor.write(prop+"\n");
Asynchronous dialog:
%SCRIPT
var ui = createUI(" ... path to your ui file ...");
ui.accepted.connect(function(){alert("x");})
registerAsBackgroundScript("abc");
ui.show();
//load dialog
//react to dialog closing
//keep function valid
//show dialog
The dialog is described in an ui file which can be created with the Qt Designer.
Calculator:
%SCRIPT
currentLine=editor.text(cursor.lineNumber());
from=currentLine.lastIndexOf("%")+1;
to=currentLine.lastIndexOf("=");
if (from>=0 && to > from) {
toEvaluate = currentLine.substring(from, to);
with (Math) { value = eval(toEvaluate);}
cursor.eraseLine();
cursor.insertText(currentLine.substring(0, from)+toEvaluate+"="+value);
cursor.insertLine();
cursor.movePosition(1,cursorEnums.Left );
}
This will evaluate everything between % and = and write the result after the =. You can use it like a calculator if you write %5+3= in the tex file.
(tikz) Coordinate pair mover:
%SCRIPT
var doit = function(){
var mytext=cursor.selectedText();
var regExNumberPre = " *[0-9]+([.][0-9]*)? *";
var regExDigit = /[0-9]/;
var regExSpace = / /g;
var regExPairPre = " *(-?"+regExNumberPre+")";
var regExPair = new RegExp("()[(]"+regExPairPre+","+regExPairPre+"[)]"); ;
//read first coordinate pair
var regExFirstPairPre = regExPairPre + " *([+-]"+regExNumberPre+")?";
var regExFirstPair = new RegExp("()[(]"+regExFirstPairPre+","+regExFirstPairPre+"[)]");
//extract offsets (start regex search from first digit, to allow -x - y)
var matches = regExFirstPair.exec(mytext);
if (matches == null) throw "missing";
//throw matches;
var offsetXPre = matches[4];
var offsetYPre = matches[8];
if (offsetXPre == "" && offsetYPre == "") throw "abc";
var offsetX = offsetXPre == ""?0.0:offsetXPre.replace(regExSpace, "")*1.0;
var offsetY = offsetYPre == ""?0.0:offsetYPre.replace(regExSpace, "")*1.0;
//move first pair
var matchpos = mytext.search(regExFirstPair);
editor.write(mytext.slice(0,matchpos));
editor.write("("+(matches[2].replace(regExSpace, "")*1.0+offsetX));
editor.write(", "+(matches[6].replace(regExSpace, "")*1.0+offsetY)+")");
//move other pairs
var remaining = mytext.slice(matchpos+matches[0].length);
while (remaining != ""){
matches = regExPair.exec(remaining);
if (matches == null) break;
matchpos = remaining.search(regExPair);
editor.write(remaining.slice(0,matchpos));
remaining = remaining.slice(matchpos+matches[0].length);
editor.write("(" + ((matches[2].replace(regExSpace, "")*1.0)+offsetX) + ", "+ ((matches[4].replace(regExSpace, "")*1.0)+offsetY) + ")");
}
editor.write(remaining);
}
doit();
This will add to all selected coordinate pairs the offset of the first pair which translates all pairs in a given direction. E.g. if you have (1 + 1, 2 - 1.5) (3, 4) it will change it to (2, 0.5) (4, 2.5).
09/12/2015 10:33 PM
22 of 29
http://texstudio.sourceforge.net/manual/current/usermanual_en.html
4.5.4 Triggers
Meaning
(?language:...)
The macro is only active if the highlighting of the document matches the given language.
Example: (?language:latex)
(?highlighted-as:...)
Restrict the macro to certain highlighted environments. The possible values correspond to the list on the syntax highlighting config page.
Example: (?highlighted-as:numbers,math-delimiter,math-keyword)
(?not-highlighted-as:...) Similar to (?highlighted-as:...), but the macro is deactivated in the given environments.
You may combine (?language:...) and (?highlighted-as:...) expressions. However, combing (?highlighted-as:...) and (?not-highlighted-as:...) does not make sense logically
and has undefined behavior.
Note that you still need the regular expression of the trigger itself. Here's a full complex example: (?language:latex)(?highlighted-as:comment,commentTodo)FIXME. This trigger responds
to typing "FIXME", but only in comments and todo-notes of latex documents.
Executed on Event
?txs-start
TeXstudio is started.
?new-file
A file is loaded
?load-this-file
The file containing the macro is loaded (only makes sense, if the script is defined as magic comment)
?save-file
A file is saved
?close-file
A file is closed
?master-changed
?after-typeset
?after-command-run A command run has ended (e.g. a compile command that calls latex twice and opens the viewer, will trigger this event once, but after-typeset twice)
Multiple of these special triggers can be combined by | symbols.
09/12/2015 10:33 PM
23 of 29
http://texstudio.sourceforge.net/manual/current/usermanual_en.html
Integrated pdf-viewer
TeXstudio provides an integarted pdf-viewer which offers forward- and inverse-search. Make sure that synctex is activated in the pdflatex command (option -synctex=1 needs to be added), though
TeXstudio will ask you if it can correct the command itself if it is not set correctly.
Forward search is automatically done every time the pdf-viewer is opened. TeXstudio will jump to the position where your cursor is currently positioned. Additionally you can CTRL+left click on a
word in the text editor to jump to the pdf or use the context menu and select "Go To PDF".
Inverse can be activated by clicking in the pdf with CTRL+left mouse button or by slecting "jump to source" in the context menu, which is activated with a right mouse button click. Furthermore it is
possible to enable "Scrolling follows Cursor" in pdf-viewer/configure. This will keep the pdf-viewer position synchronous to your cursor oposition in the editor. Likewise "Cursor follows Scrolling"
keeps the editor position synchronous to pdf-viewer position.
09/12/2015 10:33 PM
24 of 29
http://texstudio.sourceforge.net/manual/current/usermanual_en.html
Below you can find a list of commands for some common viewers. Of course, you have to replace (your program path) with the path of the program on your computer, if you want to use a
command.
Sumatra
Launch Sumatra from TeXstudio and configure Sumatra for inverse search: "(your sumatra path)" -reuse-instance -inverse-search "\"(your TeXstudio path)\" \"%%f\" -line
%%l" "?am.pdf"
Jump to a line in a running Sumatra (Windows only): dde:///SUMATRA/control/[ForwardSearch("?am.pdf","?c:am.tex",@,0,0,1)]
Launch Sumatra if it is not running and jump to a line in it (Windows only): dde:///(your sumatra path):SUMATRA/control/[ForwardSearch("?am.pdf","?c:am.tex",@,0,0,1)]
Launch TeXstudio from Sumatra: "(your TeXstudio path)" "%f" -line %l
A possible value for (your Sumatra path) is C:/Program Files/SumatraPDF/SumatraPDF.exe
Foxit Reader
Launch Foxit Reader from TeXstudio: "(your Reader path)" "?am.pdf"
Acrobat Reader
Launch Acrobat Reader from TeXstudio: "(your Reader path)" "?am.pdf"
Naviation and closing are achieved via DDE commands. Since version 10 of the adobe products the DDE service name contains a letter for the Product and the version number.
Product
Service name
Adobe Reader 9
acroview
Adobe Acrobat 9
acroview
xdvi
Launch xdvi from TeXstudio: xdvi %.dvi -sourceposition @:?c:m.tex
Launch xdvi from TeXstudio and enable inverse search: xdvi -editor "texstudio %f -line" %.dvi -sourceposition @:%.tex
kdvi
Launch kdvi from TeXstudio: kdvi "file:%.dvi#src:@ ?c:m.tex"
Okular
Launch okular from TeXstudio: okular --unique %.dvi#src:@?c:m.tex
Launch TeXstudio from Okular: texstudio %f -line %l
Skim
Launch Skim from TeXstudio: (your Skim path)/Contents/SharedSupport/displayline @ ?am.pdf ?c:ame
Launch TeXstudio from skim: Command: /applications/texstudio.app/contents/macos/texstudio with arguments: "%file" -line %line
A possible value for (your Skim path) is /Applications/Skim.app
qpdfview
09/12/2015 10:33 PM
25 of 29
http://texstudio.sourceforge.net/manual/current/usermanual_en.html
Defines the language used for spell checking of the document. This overrides the global spellchecking settings. Nevertheless, an appropriate dictionary has to be installed.
% !TeX encoding = utf8
Defines the root document for this file (i.e. the file which will be passed to the LaTeX compiler when building). This setting override the automatic root detection in TeXstudio. In turn, it's
overridden, if an explict root document is set at Options -> Root Document.
% !TeX program = pdflatex
Defines the compiler to be used for the document. To be precise, it overrides the default compiler (command txs:///compile) which is used in the actions "Build & View" as well as
"Compile".
% !TeX TXS-program:bibliography = txs:///biber
This is a TeXstudio-specific setting. It overrides the build-system command specified to the left by the one on the right. In the example, we tell TXS to use the biber command
(txs:///biber) for the general "Bibliography command (txs:///bibliography). See also the description of the build system.
%
%
%
%
%
This defines a temporary javascript macro which is executed, when the file is loaded, and which in turns loads the two files in /tmp/test. .
The macros defined via TXS-SCRIPT are active in all files of a document (e.g. included files). You cannot run them manually. They are run via the trigger (regular expression or special
trigger, see section on triggers). The macro is just read once, when the file is opened. Changes during an edit session will only take effect when you reopen the file.
% !BIB program = biber
The special % !BIB program command is understood for compatibility with TeXShop and TeXWorks (also in the variant % !BIB TS-program). This is equivalent to % !TeX
TXS-program:bibliography = txs:///biber
defines the document as explicit root document (formerly called master document).
--line xx[:cc]
TeXstudio will jump to the xx line after loading the document. Optionally you can add a target column separated by a colon, e.g. "--line 2:5" will jump to column 5 in line
2.
--insert-cite
citation
Pushes a bibtex key to TeXstudio, that will be inserted at the cursor position. This is intended as an interface for external bibliography managers to push citations to
TeXstudio. You may either pass an (also custom) command like \mycite{key} or just the key. In the latter case, it is expanded to \cite{key}. Also comma separated keylists
are supported. TeXstudio recognizes, if the cursor is already within a citation macro. If so, only the key is inserted at an appropriate position, otherwise the full citation
command is inserted.
--start-always
TeXstudio will start, even if another instance of it is already running. This allows using of multiple instances.
--pdfviewer-only
--page
Note: The most common tests are run automatically, if there were changes to the executable (i.e. TXS has been compiled since the last run). Furthermore all tests are run once a week.
09/12/2015 10:33 PM
26 of 29
http://texstudio.sourceforge.net/manual/current/usermanual_en.html
If no classification is given, the command is considered valid at any position in a LaTeX document. The char # cannot be used inside a command, as it has special meaning:
#include:<packagename> (at start of line): also load packagename.cwl. This should be used to indicate that a package depends on other packages.
#repl:<search> <replacement> (at start of line): define a letter replacement, e.g. "a -> for German. Only used for letter replacement in spell checking (babel)
#keyvals:<command> (at start of line): start definition of keyvals for command, see graphicx.cwl in source code. To specify possible values for keys, add them after # e.g. mode=#text,math
Instead of single keys/values, complete special lists can be given, e.g. color=#%color, see also tikz.cwl.
command can consist of two parts, e.g. \documentclass/thesis which is only valid when the command \documentclass uses thesis as argument.
If #c is added, the keyvals are only used for completion, not for syntax checking
#endkeyvals (at start of line): end definition of keyvals, see graphicx.cwl in source code
#ifOption:<option> (at start of line): the following block is only loaded if <option> was used in the usepackage command, e.g. \usepackage[svgnames]{color} -> option=svgnames
#endif (at start of line): end conditional block
# (at start of line with the exception of #include,#repl,#keyvals or #endkeyvals ): This line is a comment and will be ignored.
# (in the middle of a line): Separates the command from the classification
Argument Names
The argument names are visible in the completer window and after completion as placeholders in the editor. In general, you are free to name the arguments as you like. We encurage to provide
meaningful names e.g. \parbox[position]{width}{text} instead of \parbox[arg1]{arg2}{arg3}.
There are a few argument names that have special meaning:
text or ends with %text: The spellchecker will operate inside this argument (by default arguments are not spellchecked).
title or short title: The spellchecker will operate inside this argument (by default arguments are not spellchecked). Furthermore the argument will be set in bold text (like in section)
bibid and cite key: If used in a command classified as "C". See the classifier description below.
cmd and command or ends with %cmd: defintion for command, e.g. \newcommand{cmd}. This "cmd" will considered to have no arguments and convey no functionality.
def and definition: actual defintion for command, e.g. \newcommand{cmd}{definition}. This "definition" will ignored for syntax check.
args: number of arguments for command, e.g. \newcommand{cmd}[args]{definition}.
package:package name, e.g. \usepackage{package}
title and short title:section name, e.g. \section{title}
color:color name, e.g. \textcolor{color}
width,length,height or ends with %l:width or length option e.g. \abc{size%l}
cols and preamble:columns defintion in tabular,etc. , e.g. \begin{tabular}{cols}
file:file name
URL:URL
options:package options, e.g. \usepackage[options]
imagefile:file name of an image
key:label/ref key
label with option #r or key ending with %ref:ref key
09/12/2015 10:33 PM
27 of 29
http://texstudio.sourceforge.net/manual/current/usermanual_en.html
Meaning
unusual command which is used for completion only in with the "all" tab. This marker may be followed by other classifications.
do not show in completer at all. This marker may be followed by other classifications.
this command declares a complex citation like "\textcquote{bibid}{text}". The key needs to be given as bibid
this command declares a url command like "\url{URL}, where URL is not checked"
this command declares a todo item (will be added to the todo list in the side panel)
this command declares a color (will be used for color completion only, no syntax checking)
this command declares a special definition, the definition class is given after a "#". The class name needs a preceding %. (e.g. %color), also see the examples below.
environment alias, means that the environment is handled like the "env" environment. This is useful for env=math or tabular.
The classifiers specifying the meaning of arguments (like c or i) always apply to the first non-optional parameter. This is a current limitation of the cwl format and the LaTeX parser in TXS. For
example \ref{label}#r and \ref[option]{label}#r will work as expected, but \ref{arg}{label}#r will interpret arg as reference. We recommend not to specify any class in such a case.
Examples:
Line
Explanation
# test
comment
\typein{msg}#*
\sqrt{arg}#m
\pageref{key}#r
\vector(xslope,yslope){length}#*/picture
\begin{align}#\math
declares that the "align"-environment is handled like a math-env, concerning command validity and syntax highlighting!
Place the cursor inside the table and select the menu "Latex/Manipulate Tables/Remodel Table Using Template".
Now you can select a template which defines the formating of the table. A number of templates are predefined by txs:
fullyframed_firstBold
fullyframed_longtable
plain_tabular
plain_tabularx
rowcolors_tabular
By selecting the first entry, the table is reformated to:
\begin{tabular}{|l|l|}
\hline
\textbf{a}&\textbf{b}\\ \hline
c&d\\ \hline
09/12/2015 10:33 PM
28 of 29
http://texstudio.sourceforge.net/manual/current/usermanual_en.html
\end{tabular}
These templates give the opportunity to easily reformat tables after a predefined fashion, thus achieving a uniform table style in a document, even if the tables are entered in a very simple style.
The template itself is a javascript (see above) with some prefined variables which contain the whole table. The new table is just placed as replacement of the old one, using information from that
variables. 3 variables are given:
def the simplified table definition without any formatting (i.e. ll instead of |l|l|)
defSplit the table definition split by column (array=l,l,p{2cm})
env the actual enviroment name of the old table like "tabular" or "longtable"
tab the actual table. It is a list of lines, each line is a list of columsn which contains the cell content as string
To see the principle of work, the source for the "plain_tabular" template is given here.
function print(str){ //define this function to make source more readable
cursor.insertText(str)
}
function println(str){ //define this function to make source more readable
cursor.insertText(str+"\n")
}
var arDef=def.split("") // split the table definition (ll -> 'l' 'l')
println("\\begin{tabular}{"+arDef.join("")+"}") //print table env
for(var i=0;i<tab.length;i++){ // loop through all rows of the table
var line=tab[i]; // line is a list of all columns of row[i]
for(var j=0;j<line.length;j++){ // loop through all columns of a row
print(line[j]) // print cell
if(j<line.length-1) // if not last columns
print("&") // print &
}
println("\\\\") // close row with \\, note that js demands for backslashes in the string
}
println("\\end{tabular}") // close enviroment
As can be seen in the example, the table has to be rebuilt completely, thus allowing new formatting. A second example gives a slightly more elaborate table (fullyframed_firstBold):
function print(str){
cursor.insertText(str)
}
function println(str){
cursor.insertText(str+"\n")
}
if(env=="tabularx"){
println("\\begin{tabularx}{\\linewidth}{|"+defSplit.join("|")+"|}")
}else{
println("\\begin{"+env+"}{|"+defSplit.join("|")+"|}")
}
println("\\hline")
for(var i=0;i<tab.length;i++){
var line=tab[i];
for(var j=0;j<line.length;j++){
var col=line[j];
var mt=col.match(/^\\textbf/);
if(i==0 && !mt)
print("\\textbf{")
print(line[j])
if(i==0 && !mt)
print("}")
if(j<line.length-1)
print("&")
}
println("\\\\ \\hline")
}
println("\\end{"+env+"}")
09/12/2015 10:33 PM
29 of 29
http://texstudio.sourceforge.net/manual/current/usermanual_en.html
Example
The following is a small example which specifies some highlighting of python code:
python.qnfa
<!DOCTYPE QNFA>
<QNFA language="Python" extensions="py" defaultLineMark="">
<sequence parenthesis="round:open" parenthesisWeight="00">\(</sequence>
<sequence parenthesis="round:close" parenthesisWeight="00">\)</sequence>
<!-- highlight def and function name -->
<sequence id="python/definition" format="python:definition">def$s?$w*</sequence>
<sequence id="python/number" format="python:number">[0-9]+</sequence>
<list id="python/keyword" format="python:keyword">
<word>return</word>
<word>if</word>
<word>elif</word>
<word>else</word>
</list>
</QNFA>
python.qxf
<!DOCTYPE QXF>
<QXF version="1.0" >
<!-- full specification -->
<format id="python:keyword" >
<bold>false</bold>
<italic>false</italic>
<overline>false</overline>
<underline>false</underline>
<strikeout>false</strikeout>
<waveUnderline>false</waveUnderline>
<foreground>#B200FF</foreground>
</format>
<!-- but it is sufficient to specify deviations from default -->
<format id="python:number" >
<italic>true</italic>
<overline>false</overline>
<foreground>#007F0E</foreground>
</format>
<format id="python:definition" >
<bold>true</bold>
</format>
</QXF>
Changelog
The changelog can be found at http://texstudio.sourceforge.net/manual/current/CHANGELOG.txt.
09/12/2015 10:33 PM