This page should automatically redirect to an updated version of these instructions. If it does not, please click here: http://www.pauljhurtado.com/teaching/software.html.
TeXstudio Setup
Below are instructions to (1) install a
dark editor theme for TeXstudio, and (2) instructions to
configure TeXstudio to work seamlessly with R and knitr -- a powerful way to integrate R (or python, etc.) code into a LaTeX document, and have that code and/or it's output appear in the document without any additional formatting by you!
Note: For now, this only has instructions for Windows. It should be similar on OS X and Linux, so let me know if you try!
Configure TeXstudio to use R + knitr
Instructions:
- You need to have installed the following software in the given order. Rstudio is optional, but is my recommended way of using R. It should be installed AFTER MikTeX and R if you'd like to compile R Markdown documents as well as knitr documents via Rstudio.
- MikTex
- R
- RStudio (optional)
- Start up R, and install the "knitr" package with the command
install.packages("knitr")
- Install TeXstudio
This should be relatively painless! If you run into trouble, Google is your friend.
- Configure TeXstudio to compile knitr documents.
Go to Options > Configure TeXstudio > Build and edit the "User Commands" to read "C:\YOUR-R-DIRECTORY\bin\x64\Rscript.exe" -e "knitr::knit2pdf('%.Rnw')"
Note: the long filename for Rscript.exe needs to reflect where R files are located on your computer!
See also http://yihui.name/knitr/demo/editors/
- Configure a Keyboard Shortcut to compile knitr (*.Rnw) documents:
Once the User Command above is defined, you can assign a keyboard shortcut to quickly compile knitr (*.Rnw) files. TeXstudio recently changed the default shortcut to "Build & View" a LaTeX (*.tex) document from F1 to F5. So, I use the shortcut F4 to build knitr (*.Rnw) documents. Another alternative might be Shift+F5. (Note that F7 will display the PDF, once compiled.)
Begin by going to Options > Configure TeXstudio > Shortcuts > Tools > User.
Click the second column ("Current Shortcut") entry for knitr then hit the F4 key (typing "F" then "4" will not work!). Optional: Click the 3rd column (Additional Shortcut) and set it to Shift+F5.
Now save, and you should be all set!
- To test it out, download this knitr example and try to compile it by hitting F4: homework-knitr-template.Rnw
Dark Color Theme for TeXstudio Editor
Instructions for installing a pre-configured dark theme for the TeXstudio editor:
- Download a dark color theme:
- My dark theme:
Texstudio-dark-Hurtado.txsprofile
- Various examples at http://tex.stackexchange.com/questions/108315/how-can-i-set-a-dark-theme-in-texstudio.
- My dark theme plus some editor modifications (e.g. supressed underline of grammar mistakes, etc.):
Texstudio-darkplus-Hurtado.txsprofile
- Open up the color theme in a text editor (I prefer notepad++).
- Next come the "not-so-user-friendly" steps, so let me walk you through them!
- Go to Options > Save profile... and save a backup of the current profile to something like
user-default.txsprofile
.
- Do this again, but instead save to a file named something like
custom-dark1.txsprofile
. Note the directory this file is saved it!
- Open
custom-dark1.txsprofile
(or whatever you named it) with a text editor (again, I like notepad++) and scroll to the very bottom which should look like
...
[formats]
version=1.0
Note these are the first two lines of the dark theme file you downloaded!
Copy and paste the contents of the dark them to this section of custom-dark1.txsprofile
file and save. The [formats] section of custom-dark1.txsprofile
should now read
...
[formats]
version=1.0
data\normal\priority=-1
data\normal\bold=false
...
- Go to Options > Load profile... and load the newly edited
custom-dark1.txsprofile
.
- Restart TexStudio and open a file, and you should see the dark themed editor!
- Finally, you can further modify your color scheme by going to Options > Configure TeXstudio > Syntax Highlighting