Friday, November 25, 2011

LaTeX Tip: TeXstudio

I have spent the last few days designing documents with LaTeX, using the XeTeX engine. The process has produced some great results, but a good amount of digging was required to find out rather obvious things. This series of articles will hopefully save you this time.

I will assume you've installed TeX Live in the default location, which is C:\texlive on Windows 7. There are two distributions that use XeTeX and only this one worked for me, as I wrote previously. Of course you don't have to use Windows; these are cross-platform open source applications.

The first thing to do is get a good text editor! You may already use an editor that has a custom TeX mode. If so, great. Otherwise I suggest something like TeXstudio. This provides syntax highlighting, easy access to common commands, auto-completion, outline folding, and command line integration. Working any other way is a needless pain.

Wikipedia has a comparison of TeX editors. You may think it a good idea to get a graphical WYSIWYM ("what you see is what you mean") editor so you don't need to compile your mark-up manually to see the result. But my experience is the opposite. I tried LyX and was disappointed by the usability. TeX markup is text; it's best to view and work with it as text.

The next thing to do is set up the correct commands in TeXstudio, so that you can compile your work and view the results in a single keystroke. Use the menu to navigate to User > User Commands > Edit User Commands. Name a new menu item XeTeK and copy and paste the following for the command string: "C:\texlive\2011\bin\win32\xelatex.exe" -interaction=nonstopmode %.tex | tmx://internal-pdf-viewer. Now go to Option > Configure TexStudio and choose the big graphical tabs from the left-hand panel. Then find the same menu item you just defined in the right panel, in Menus > User > User Commands > XeTex. If you double-click on this you can choose which key to bind to this command, say F1.

Now each time you want to see the result of your editing, tap F1 and the PDF will be generated and displayed in a separate window for inspection. This viewer remembers your position in the document, which is handy. In all ways it acts like a slim version of Adobe Reader.

Similar configuration will apply to your chosen text editor. Oh yes, if you have a favourite, why not comment and let me know? TeXstudio works fine, but has some non-standard peculiarities, such as the way Search and Replace works. I wouldn't mind taking your advice and getting something better, so long as it works on Windows and is free to use (since I already have a commercial editor).

More LaTeX tips in my next article.


1 comment:

Anonymous said...

Texstudio rocks, I've been using it for about 1 year now. I used to have MikTeX with TeXNicCenter on Windows and TeXstudio with Kile on Ubuntu, but with TeXstudio I have one system for both Windows and Linux, so that's more efficient, as I keep going from one OS to the other. The latest version of TexStudio is 2.4, just set it up this week, it's even better than 2.3.

Post a Comment