lunedì 12 ottobre 2009

LaTeX: installing editor & pdf viewer

Once you've installed TeXLive on your Windws Vista PC, the game is not over, yet.
In fact, LaTeX itself is the "engine" (the compiler), but to produce and see/print your documents you will need*:
- a specific LaTeX Editor;
- a (specific) PDF viewer.

*Please Note: actually, you don't need a specific LaTeX editor; in fact, you can type your LaTeX document wherever you want (i.e. Notepad) and save them with *.tex extension (not *.txt). Nonetheless, a specific editor would help you in a such numerous things... so... Why not?

I'll describe you TeXnicCenter editor and SumatraPDF-TeX viewer.


TeXnicCenter is an Open Source editor, really customizable, available for download at http://www.texniccenter.org/.
The installation process is a Windows standard one (you just have to run a exe file).
The first time you run TeXnicCenter, the software will ask you about your LaTeX distribution path, your default viewer path, etc.
You'll early learn using TeXnicCenter. Just a couple of tips and tricks.

First of all, the spelling.
TeXnicCenter can spell your documents in real time - if you give him a dictionary (language_DIALECT.dic and language_DIALECT.aff). To do this, click Tools - Options - Spelling, in Default Language select a dictionary and a dialect, in Personal Dictionary field type the path of your dictionaries folder. Clicking Download Dictionaries (and being connected to internet), an OpenOffice wiki services web pages with links to all dictionaries available will open - just download the *.zip file and uncompress the two previously cited files in the appropriate folder).
For Italian people, download "Italian dictionary (dizionario italiano)" in Spelling submenu, unzip it_IT.dic and it_IT.aff.

One more interesting thing; auto-completation.
While typing your LaTeX document in TeXnicCenter, you'll se a small yellow tips window appear every time you're typing a LaTeX command that TeXnicCenter recognize - just press ctrl + space to accept the suggestion. May be you want to edit / customize the autocompletation: see here (in Italian only).

With the third tip, we'll get inside the second argument of this post: a pdf viewer.
Every Windows user feels comfortable with Acrobat Reader - and that's OK. But, others pdf viewer are more suitable while your document preparation is a WIP. This means: you can get forward and inverse search from the output pdf and the source tex file.

Quoting http://william.famille-blum.org/
SumatraPDF is a PDF reader which supports two synchronization technologies: pdfsync and the more recent SyncTeX. To use the first one you just need to load the 'pdfsync' package in your latex document as follows: \usepackage{pdfsync} When compiling your source file, LaTeX will generate a .pdfsync file along with the .pdf output file. This file can then be used by SumatraPDF to perform synchronization. With SyncTeX it is not necessary to load any package. However you need to specify the 'synctex' switch when compiling your document with pdflatex: pdflatex -synctex=-1 document.tex Also make sure you have updated your TeX installation as only recent releases of pdftex support this feature (TeXLive 2008 and MikTex 2.7).

We'll talk about SyncTeX.
Quoting again:
SyncTex is directly integrated in pdftex. This has many benefits: there is no need to load a special package in your .tex document, there is no more incompatibilities with latex packages, and the synchronization is more precise. One disadvantage is that the generated synchronization file can be huge, and for that reason it has an option to zip it. One disadvantage is that the generated synchronization file can be huge, and for that reason it has an option to zip it.

So, download SumatraPDF-tex.exe from this page: http://william.famille-blum.org/software/sumatra/index.html
The file you download is the executable files yet (no installation required): move the file (for i.e.) in C:\Program Files\SumatraPDF\ and everytihing is done.

OK, now. Having installed TeXLive 2008 (or MikTeX 2.7 and followers), you won't need anything but compiling with the option -synctex=-1*, so:
pdflatex -synctex=-1 test.tex

*Please Note: -synctex=1 will produce the zipped version of synctex file.

Let's go back to TeXnicCenter: select Build - Definse Output profiles... and set in (La)TeX tab the field as follows (eventually in a new profile copied from LaTeX -> PDF):



Again in Viewer tab:



I quote one more time for the textual part to copy - paste:
1- Menu 'Build\Define output profiles...'
2- Select the profile "Latex=>PDF"
3- Select the tab '(La)TeX'
4- In the field 'Command line arguments to pass to the compiler' add -synctex=-1.

Forward search
To setup forward-search with TeXnicCenter proceed as follows:
1- Menu 'Build\Define output profiles...'
2- Select the profile "Latex=>PDF"
3- Select the tab 'Viewer'
4- Fill the options as follows:
Path of executable: c:\tools\SumatraPDF-sync.exe -reuse-instance
Forward search: select DDE command
Command: [ForwardSearch("%bm.pdf","%Wc",%l,0,0,0)]
Server: SUMATRA
Topic: control
View project's output: select DDE command
Command: [Open("%bm.pdf",0,1,1)]
Server: SUMATRA
Topic: control
Close document before running (La)TeX: Do not close

OK, we're near at the end - we only have to set up the inverse search.
Now just open SumatraPDF, click con Sttings - Options and in the field "Set inverse search command line" the string to start TeXnicCenter is:
"C:\Program Files\TeXnicCenter\TEXCNTR.EXE" /ddecmd "[goto('%f', '%l')]"

Done!

2 commenti:

Doc ha detto...

Grazie mille, mi è stato utilissimo!

Anonimo ha detto...

Grazie a te per il commento.

Google

in tutto il web in 16marzo
Per scrivere con caratteri a spaziatura fissa
  questo è il codice 
And what about this one?