Install LaTeX for Windows 7 – a complete setup

To use LATEX is one thing, and very good introductions exist for learning. But what do you need for installing a LATEX system on Windows? What do I do with TEX Live, why do I need Ghostscript, what’s TeXmaker, and why many people favor Emacs, and above all, how does everything fit together?

This tutorial shall save the search an show step by step what you need and how to setup the individual components.

Das LaTeX-Buch bestellen.

I am always happy about suggestions and notes on possible errors. When reporting by mail, please always include the file date: December 11, 2013

Many thanks to a number of readers for suggestions and corrections.

The correct addresses for this document are:

The German version is available via


1 Everyone can set up LATEX

LATEX is not just a program but a language and a methodology of describing documents and gets used via a LATEX system. With that not only scientific papers can be prepared, but also excellent letters, presentation and much more.

For all that have not worked with free software so far it may be strange in the beginning to have to integrate different components to a system on their own, and some will not easily have the heart to do so. For this I present my own environment that I use to generate from LATEX PostScript and PDF as well as HTML.

This is not a introduction to LATEX, there are some excellent documents available in the net as well as my book[16]. For beginners the best will be the “Not so short introduction to LATEX2ε”, delivered with approximately every LATEX distribution in <texmf>/doc/guides/lshort/, or to be downloaded from CTAN.org1. Essential also is the UK TEX FAQ, to be obtained from the UK TeX Archive[3]. Then we should mention l2tabu, which lists obsolete commands and packages and their alternatives.

If you have severe problems with installation although using this tutorial, or have another question related to LATEX, should not write to me personally but search in the Internet and the FAQ. In case of continuous confusion you can post in the newsgroup Most questions can be answered there, and also concerning Windows installation this is preferrable, because answers are for everyone’s benefits and numerous competent users and developers read along.

This guide was testet under Windows 7, but should work as well with Windows 8 and XP. It is not a substitute for the original documentations of the particular programs and building blocks 2. In case of errors or warnings, consult the documentation of the particular program. This tutorial exclusively cares for the mentioned programs. Sections concerning Emacs, as an example, cannot be transferred for XEmacs without special care. More recent versions of programs usually work well (no guarantee).

2 What do you need at all?

In order to be able to work efficiently, besides the main TEX distribution more components are needed.

LATEX Distribution:TEX Live The LATEX distribution is the core of the system. It contains the most important programs needed for generation of DVI, PostScript and PDF, and all additional packages for e. g. standard layouts for different organizations, layout specialties, fonts, and many more.

The distribution is only responsible to transform an input to an output. The input itself is created with the editor of your choice. I use TEX Live. In my opinion this distribution is easy to install, works quite good and is updated regularly.

Editor: Texmaker For keeping the beginning with LATEX as simple as possible, I recommend Texmaker as Editor, differing from my personal setup.

I will skip instructions for the also popular TeXlipse, the Eclipse plugin. Everyone using Eclipse will manage to get that additional package.

For pure mouse oriented users Texmaker is quite comfortable. Texmaker is well updated and convenient to use, because besides graphical menus for most mathematical symbols and all relevant commands it shows so called tool tips during typing of commands. Especially for a newbie in LATEX Texmaker is recommendable. Later you can switch to Emacs.

Nevertheless it has to be stressed that Texmaker misses some features that I like in Emacs, e. g. a numerated table of contents view or a powerful handling of labels and cites. The integrated spell-checker does not yet show the quality as Aspell does for Emacs.

Editor: Emacs + RefTeX + AUCTeX + Aspell Please do skip Emacs if you are new to LATEX.

If you already have worked with LATEX under Unix, you might have used Emacs, one of the most powerful GNU programs.

I decided to switch to Emacs due to the add-ons AUCTeX and RefTeX. AUCTeX offers keyboard shortcuts for all important LATEX constructs, speeding up work significantly. AUCTeX additionally shows in-editor preview of graphics, tables and formulas. This merges the best from both worlds WYSIWYG and offline editing[10]. On insertion of cross references, RefTeX lets the user select one out of a list of all existing labels, and does help with generation of these labels. Also insertion of bibliographic cites is efficient and fast with RefTeX. Read the introductions or tutorials for Emacs and AUCTeX and get the Emacs reference card. The initial learning effort pays out, it is overcompensated by fast and efficient working.

Moreover you have a spell checker called Aspell in Emacs. It contains dictionaries for English, German and many others.

Graphics in PostScript with Ghostscript In the Unix world, PostScript is the exchange format for vector graphics. Following this paradigm, it is best to include graphics as (Encapsulated) PostScript (PS/EPS) in LATEX.

From all Windows applications with their file formats, e. g. existing Word- or PowerPoint drawings, Bitmaps or vector files like Visio, PostScript can be generated even if the application does not support this directly. A PostScript printer driver, redirected to file output, makes this possible. For viewing existing PostScript files and to make small changes you need Ghostscript with its graphical front-end GSview.

HTML translation: TeX4ht TeX4ht has the advantage that it is contained as package in the TEX Live distribution. For usage see documentation in <texmf>/doc/generic/tex4ht. TeX4ht, requires the program ImageMagick for graphics conversion.

Summary and licensing The included package sizes mean the download sizes, not the space needed for installation.

All of the programs mentioned in this tutorial are at least free of charge, in most cases even free software3. All licenses state that the distribution is allowed. Most of them allow furthermore to change the source code, whereas some of them prohibit commercial sale.

You are invited to reward the individual projects financially. Each projects’ web page tells you how.

3 Installation and Configuration

My system runs on Windows 7. Some access paths to certain configurations may deviate on your system from the described. Access paths denominate entries in the start menu, buttons and menu entries with their particular captions.

The step sequence is to be followed tightly due to program dependencies. If you use another directory for a program, please to take care about this in subsequent steps.

3.1 Download and install TEX Live

Start by downloading the TEX Live installer from for Windows. If you only have a thin internet connection, use the same page to order the TEX Collection DVD.

Unpack the Zip file and from the created folder call the program install-tl.bat. Accept all defaults and leave your computer alone for the next couple of hours – depending on your internet connection.

After finishing the installation, all programs can then be started directly from command line.

3.1.1 Install Additional Fonts

The TEX Live installer contains only fonts whose license allow distribution on DVD. So some are missing where this is not allowed, but which may be used free of cost. Now we install these.

Therefore we download the script getnonfreefonts [getnonfreefonts ]. Open a command line and change to your download folder. Enter the following two commands:

   texlua install-getnonfreefonts getnonfreefonts-sys -a

This first installs getnonfreefonts, then downloads and installs all available free fonts for all local TEX users. If you do not have administrator privileges on your computer, substitute the second line with this one:

   getnonfreefonts -a

3.2 Graphics Preparation and Conversion

Configure the PostScript printer driver bySTART| DEVICES AND PRINTERS| ADD PRINTER . First you select local printer and as adapter the FILE port, the right printer driver is the MS Publisher Color Printer (from Windows 7 on, “Generic” in the vendor list), resp. Apple Color LaserWriter 12/600 (up to Windows Vista). The printer name is best set to “PostScript File”.

After installation do the following settings underSTART| DEVICES AND PRINTERS | POSTSCRIPT FILE| PRINTER| PRINTING PREFERENCES| ADVANCED| DOCUMENT OPTIONS | POSTSCRIPT OPTIONS : Set PostScript-Output to “Optimize Portability” and TrueType Download to “Contour”. The ICM Color Matching should be deactivated for avoidance of color adulterations.

From now on every Windows application can produce PostScript files by using the new printer. The generated file—which should be given the file extension .ps instead of the default .prn—can be viewed in GSview and converted to EPS. It exceedingly useful to add Ghostscript to the search path. So again, inSTART| CONTROL PANEL| SYSTEM AND SECURITY| SYSTEM| ADVANCED| ENVIRONMENT VARIABLES add to the variable PATH the respective folder C:\texlive\2013\tlpkg\tlgs\bin\, separated by a semicolon. Attention: No spaces before or after entries of the PATH variable!

In order to simplify work in the long run I recommend to setup an “EPS Printer”, for this I have a short tutorial, too: [15]. Only in German, sorry, but Google Translate will do a fair job.

3.3 Configure Texmaker

The installer for Texmaker has to be executed with administrative permissions. To do so, right click on the installer in your download folder and click on “Run as administrator”.

Texmaker is installed quite rapidly: Like with MiKTEX simply accept all installer defaults.

3.4 Configure Emacs

One defect of Windows has to be fixed first: the absence of the environment variable HOME. Environment variables allow to set paths or generally strings independent of particular applications, and use them with all applications. For this create a new entry inSTART | SETTINGS| CONTROL PANEL| SYSTEM| ADVANCED| ENVIRONMENT VARIABLES 4, named HOME and assign some path in which you like to have saved all individual settings. The directory name should not contain spaces. Then create exactly that folder.

For all environment variables it is to be reckoned that if you want to set an environment variable just for the current user, you create it in User Variables. If they should apply to all users, create them in System Variables.

You need GNU Emacs for Windows (Download), and AUCTeX Windows Package (Download) as precompiled package. Unpack the Emacs archive into the programs directory, resulting in a directory like e. g. C:\Programme\emacs. In exactly this directory then unzip the archive, overwriting at least one file. Most unzippers ask before doing that.

For easier starting Emacs, in directory C:\Programme\emacs\bin run the installer addpm.exe and accept the settings. This creates a shortcut in the Windows start menu.

With this, Emacs is ready to run. To have easier access to the following configurations, you may download my Emacs configuration file with right click and “Save link as”. Rename this file to .emacs and move it to your HOME directory.

Listing 1: Contents of the file . emacs
(add-hook 'LaTeX-mode-hook 'turn-on-reftex) 
(setq reftex-plug-into-AUCTeX t) 
(setq-default ispell-program-name "aspell")

AUCTEX + RefTEX If you do not want to use my .emacs configuration file, you need to implement the follwing three paragraphs.

The integration of AUCTeX with RefTeX has to be activated separatedly. For this, start Emacs and use it to create the configuration file .emacs within you HOME directory (UNIX shortcut name ~) with C-x C-f ~/.emacs RET (The shortcut C-x stands for the keyboard combination Ctrl-x, other keys equivalent. So translates to: Ctrl-x, Ctrl-f, type “~/.emacs”, press Enter. The “~/” means the file to be located within your HOME directory.). Here you add the following lines:

(add-hook 'LaTeX-mode-hook 'turn-on-reftex) 
(setq reftex-plug-into-AUCTeX t)

Ensure that you use the straight apostrophe in the expression, not some accent or typographic single quote.

Then save the file by C-x C-s, close Emcas with C-x C-c, and the setup is completed. The installation was successful, if when opening a .tex file in the menu bar new entries “Preview”, “LaTeX” and “Ref” appear.

If you want faster and smaller preview images, you have to get the additional graphics library LibPNG from LibPNG. From the Website, download “libpng” and “zlib”. From the Binary archive extract the two DLLs libpng14-14.dll and copy them to your directory C:\Programme(x86)\emacs\bin. Do the same with the dependencies archive’s content bin\zlib1.dll, and place it in the bin directory of Emacs as well.

In PDF-Mode with (C-c C-t C-p) you now can call Preview-LATEX with C-c C-p C-d.

Aspell Aspell servers as spell checker. After downloading the program (“Full Installer”) and the dictionairy (“aspell-en-0.50-2-3.exe”) from GNU Aspell (Win32 version), first run the program installer, accepting all defaults, then your dictionairy installer.

So once again, inSTART| SETTINGS| CONTROL PANEL| SYSTEM| ADVANCED| ENVIRONMENT VARIABLES add to the variable PATH the respective directory, e. g. C:\ProgramFiles(x86)\Aspell\bin\; separated by a colon.

Finally you let Emacs know to use Aspell for spell checking in future by adding the following line to your .emacs configuration file:

(setq-default ispell-program-name "aspell")

3.5 File Types Setup

Only as a further simplification you create a new file type. First, add to your configuration file .emacs as first line:


Then download my Emacs-TEX registry file and edit it—so do not simply double click but right click and select edit. In line 6, containing the first @=, replace both occurrences of the directory name C:\\Programme(x86)\\emacs with the name of the directory you installed Emacs in. Take care that you really use two backslashes \\ path separators. Save the file and use the double click to add it to the registry. Confirm that you want it when Windows asks for.

Listing 2: Contents of the file texfile. reg
Windows Registry Editor Version 5.00 
@="C:\\Program Files (x86)\\emacs-23.3\\bin\\emacsclientw.exe -n -a \"C:\\Program Files (x86)\\emacs-23.3\\bin\\runemacs.exe\" %1 %*" 

You can do the same for further file name extensions like .bib, .sty, .cls and .lco. From then on double clicking a .tex file leads to execution of Emacs. Now Emacs is completely configured.

Now you have full system for generation of printer and camera ready documents in PDF or PostScript. If you do not want to generate HTML, you are done at this point.

3.6 Remedy if you have Admin Rights

Now start Emacs via the start menu. If your Windows user account has admin rights, you may get an error message about a rights problem of folder .emacs.d/server/.

error: The directory ‘~/.emacs.d/server' is unsafe

Fix it by changing the owner: Close Emacs. Click on Start and enter cmd into the search field. This opens a command window. Change into the Emacs"=folder below HOME by typing

cd %HOME%\.emacs.d

There you enter the following command:

takeown /f server

You only need to execute the command if you have administrative rights, and only then you are able to execute it.

3.7 Install TeX4ht and ImageMagick

TeX4ht is included in TEX Live and, if you selected the total installation, already on your hard disk for usage.

The precondition for TeX4ht on the one hand is Ghostscript that you installed in a previous section, and on the other hand ImageMagick, which gets configured as follows: Get the ImageMagick Windows Binaries from the ImageMagick web site and install it. Simply acknowledge the defaults, which automatically adds the converter program to your search path.

If you want to employ the LibreOffice export of TeX4ht, a Zip packer has to be available in the system. I apply Info-Zip for this, but only copy the file zip.exe to a directory already covered by the search path. After first use of oolatex.bat, if you discover that the generated file is corrupt, you can remedy by editing the file c:\texlive\2013\texmf-dist\tex4ht\base\win32\tex4ht.env and replace the tags <oo-alt> and </oo-alt> by <oo> bzw. </oo> and vice versa, for activating an alternative processing.

4 And now? Usage

Congratulation! TeX4ht is now installed and the TEX system can generate all important outputs.

What about exporting to Word? In principle there is no reason to export LATEX to Word, but there are programs that convert LATEX to the Rich Text Format (.rtf), which you can open in Word then. I sense the best way is via HTML or LibreOffice. This means: convert LATEX with TeX4ht to HTML or LibreOffice, and then open the output in Word resp. LibreOffice.

The generation of outputs is normally directed by the editor programs, there are buttons and/or keyboard shortcuts for this. For the usage of the Emacs add-ons I refer to their documentation. The access may be bitter, it is really worthwile.

TeX4ht usage TeX4ht is a flexible tool for converting LATEX to HTML, but with the loads of options one easily looses overview at the beginning. With a little practice, nevertheless, you can accomplish everything you imagine.

The TeX4ht documentation delivered is not so luxuriant. A comprehensive list of options, written to the log file, you get by calling

 htlatex.bat myfile.tex "info"

at the command line for a arbitrary LATEX file. Be sure to call htlatex.bat, not just htlatex, as this starts a TEX Live program instead.

Because I want XHTML as clear and as small files as possible, I tend to invoke by

 htlatex.bat myfile.tex "xhtml,2,fn-in,NoFonts,fonts,graphics-,sections+,next"

for the conversion. This generates XHTML, separate files for two levels of sections, no special font information but basic logical formatting, non-scaled graphics and helpful hyperlinks. If you like to have a more precise reproduction of the fonts, skip the option NoFonts, which of course leads to bigger files. For a monolithic file specify a 0 instead of 2.

Graphics conversion For drawing, use vector oriented programs, like e. g. CorelDraw, LibreOffice Draw, Visio or related. Generally it is strongly dis-advisable to create diagrams or graphics as bitmaps, with Photoshop, GIMP or similar programs. Applications like Excel or PowerPoint also process their graphics vector oriented, and are able to generate nice PostScript files via our PostScript printer driver. These PostScript files then get conversed to EPS [15]. MATLAB directly can produce PS/EPS.

The generated file with the extension .eps can be loaded into GSview in order to e. g. control whether the bounding box has to be corrected. The bounding box can be showed by selecting the menu entryOPTIONS| SHOW BOUNDING BOX .

In case the bounding box does not fit, the commandFILE| PS TO EPS allows to set the bounding box automatically or manually and save the output to a new file. Automatic can be selected if the whole graphic should be used. Manual selection of the bounding box is useful if unwanted head or foot lines should be cropped.

Attention: For generating PostScript or DVI graphic files have to be present in (Encapsulated) PostScript (EPS), whereas with pdfLATEX only graphics in PDF, JPEG oder PNG can be processed. It is well possible to convince the one and the other to accept all file types, but has to use special options which may make the source document unportable to other systems. If both DVI and PDF should be generated, the graphics have to exist in two formats.

If you want to use pdfLATEX to create Portable Document Format from your documents, you have to convert the EPS files to PDF. For this there is the command epstopdf, like the following:

epstopdf file1.eps

Bitmap files like JPEG or PNG can be processed directly by pdfLATEX. For usage with the normal LATEX they have to be converted to EPS using bmeps.

5 If something fails

If anything does not work or behaves apparently wrong, often the reason is a forgotten environment variable. So you first should check whether all environment variables suggested by this tutorial are set appropriately. If one misses or has a wrong value, it is possible that a succeeding installation failed, especially that of Preview-LATEX. So do it again. Another popular source of defect are files in wrong places. Go through the tutorial again and check and correct if necessary.

If needed, risk a look to the installation manual of the particular package to find more hints. Of course it cannot be ruled out that my tutorial contains an error. If you find everything in the right place and still not working, ask me and include the version number of the tutorial. Maybe I made some assumption that is not general, or a new version of a package works different.

6 Prospect

With all the possibilities offered by the numerous LATEX packages always bear in mind: Choose simple layouts and structure, especially if you plan to publish also in HTML. With help of this article nevertheless it should be possible for a reasonably Windows-experienced user to begin relatively quick with editing and typesetting texts.

If this document helps appeasing the timidity of installing and using such a system and by that lowers the inhibition threshold of the access to LATEX, it has fulfilled its purpose.



AUCTeX Windows Package (Download). URL:


Pascal Brachet. Texmaker. URL:


Robin Fairbairns. TeX Frequently Asked Questions. URL:


Ghostscript for Windows (64-bit Download). URL:


GNU Emacs for Windows (Download). URL:


GSview. URL:


Eitan Gurari. TeX4ht. URL:


ImageMagick Windows Binaries. URL:


Info-Zip. URL:


David Kastrup. »Revisiting WYSIWYG paradigms for authoring LaTeX«. In: TUGboat 23.1 (Nov. 2002), pp. 57–64.




TEX Live. URL:


Thorsten Maerz. GNU Aspell (Win32 version). URL:


Frank Neukam, Markus Kohm, and Axel Kielhorn. Das KOMA-Script Paket. package documentation. Sept. 2002.


Joachim Schlosser. EPS Writer für Windows. URL:


Joachim Schlosser. Wissenschaftliche Arbeiten schreiben mit LaTeX. 5th ed. mitp Verlag. ISBN: 978-3-8266-9486-8. URL:

1CTAN is the abbreviation for Comprehensive TeX Archive Network, the complete collection of TEX related software.

2See my post in de.comp.text.tex (in German)

3Which as is generally known is a difference to free of charge: “Free as free speech, not free beer.” See the pages of the Free Software Foundation at

4To be accessed much faster by keyboard shortcut Windows key+Break, by the way.

Creative Commons License
Install LaTeX for Windows 7 – a complete setup by Joachim Schlosser is licensed under a Creative Commons Attribution-ShareAlike 4.0 Germany License.
Based on a work at

79 Gedanken zu „Install LaTeX for Windows 7 – a complete setup

  1. Pingback: A good tutorial: how to run LaTeX/TeX for Windows 7 | Website of Nicolas Fischer

  2. Pingback: Using LaTeX with Windows 7 | Christoph Jahn

  3. Pingback: LaTeX/TeX for Windows 7 – a complete setup | Dr. Joachim Schlosser

  4. Pingback: Mit Aspell: die Anleitung für LaTeX installieren unter Win 7

  5. Etn

    Thanks for this document, it has been very helpful. I have been working on a mac and recently I decided to set up emacs (LaTeX, AUCTex, RefTeX) on windows 7.

    I would be very grateful if you could please answer one quick question. relating to the “ref” menu. I have followed your instructions (see below). When I open a .Tex file, I can see the ‘preview’ and ‘latex’ menus, however ‘ref’ menu does not appear.

    Any suggestions would be greatly appreciated, as I have also tried several codes found online.

    Many thanks


    (The environment variable was checked)

    I added the following code to my .emacs file:

    >>(add-hook ‘LaTeX-mode-hook ‘turn-on-reftex)
    >>(setq reftex-plug-into-AUCTeX t)

    >>Then save the file by C-x C-s, close Emcas with C-x C-c, and the setup is completed. The >>installation was successful, if when opening a .tex file in the menu bar new entries “Preview”, >>“LaTeX” and “Ref” appear.

    1. Joachim Artikelautor

      It’s not your fault. Please ensure that when entering the 1st line with add-hook, you set a straight apostrophe ‘ at the two places, not an accent or typographic single quotes.
      This is wrong: (add-hook ‘LaTeX-mode-hook ‘turn-on-reftex)
      This is correct: (add-hook ‘LaTeX-mode-hook ‘turn-on-reftex)
      Thanks for commenting, I will check in my document…

  6. Etn

    Thanks for your reply, however, unfortunately (after changing the apostrophes as above) the ref menu still does not appear….


    1. Joachim Artikelautor

      Please email me your full .emacs file as email attachment, and the output of the EMACS command M-x version. My email address is joachim at schlosser dot info. Thanks.

    2. Joachim Artikelautor

      Try removing all RefTeX-related configuration items from your .emacs file. Other commands might interfere with the mere 2 required in the tutorial.

      1. Aaron

        Thansk Joachim for putting this together, I appreciate it greatly!
        I would be very greatfulif you could help me with the same issue as Etn regarding the ref menu not appearing although the preview and latex menus do appear. I’m using your .emacs file (with no change)that you kindly shared and put it in a directory I set up for the HOME system variable.
        Would you have any insights as to what the problem maybe?
        Many thanks in advance!

  7. Lalit Kapoor

    Many thanks for this piece of wisdom. I was using MikTeX and TeXnicCenter for preparing LaTeX documents. I came know about Emacs and AUCTeX five days back. But after five days (and night) struggle I could not get the preview-latex results in my Emacs windows. I read every manual mutliple times. Even on net (Google) I made many searches but end up to get the same information again and again which could not help. Every thing was ok with my system. But few minutes earlier I read one specific line about ghostscript that it should be of version 8.71 not later. I simply uninstall ghostscript 9.02, download and install ghostscript 8.71 and lo . . . it works on very first run. I got the preview of my LaTeX document.

    I want to add only one thing that there is only one image support dll (i.e. libXpm.dll) included in the precompiled emacs 23.3 which you have mentioned also. For image support (like png in preview-latex) you have to download libpng.dll which should be of version 1.2 or later and copy it in the bin directory of emacs. I got libpng14_14.dll from

    Thanks again.

    1. Joachim Artikelautor

      Thanks, Lalit. Currently I am updating the guide, and the section on libpng, which I took out some months ago, will come back in. So thanks again for reminding me!

  8. Joachim Artikelautor

    The new version has arrived. Problems with setting up file types for Emacs in Windows 7 without admin rights should be past, since I threw out ftype and assoc and replaced it by entries to the registry. Another plus: the guide has become smaller again.

    Please let me know if something remains unclear. Thanks!

  9. Pavel

    Hi there Joachim:

    Thank you very much for the detailed guideline! I am starting with LaTex and you made my life easier while getting everything set for it. I just want to let you know that something went wrong in your directions for installing LibPNG, you forgot to write the last part of the paragraph including name of the two binary files (libpng3.dll, libpng12.dll) and the path for extracting them (C:\Programme(x86)\emacs\bin), which are available in you German guideline.

    Best regards,

  10. Pingback: LaTeX on WINDOWS « Tahir Iman

  11. Jin

    Thanks! First entry in google search! Very practical and useful.

    You might want to mention that “C-x” in Emacs means “Ctrl+x” etc..

    1. Joachim Artikelautor

      Thanks, Jin! The meaning Ctrl-X for C-X is mentioned in the footnote, but you are right, maybe it would be better to inline all the footnotes in the text.

  12. Wayne

    I am very interested to give auctex a try. Since I have been using Texstudio, Winedt for a while, I am so confused to customize emacs+auctex. I hope you can help me out:

    I use latex+dvi+ps+pdf+pdfviewer routine in Texstudio and Winedt. But it seems quite difficult to set such a routine in emacs+auctex.
    I saw some tips to configure latex+dvi+ps+pdf. But after the pdf file is generated by ps2pdf, I can not find a simple way to open the pdf file.
    The only way I know is to switch to PDF mode and use VIEW to open the pdf file. It is not very convenient, because I can bundle all the commands to a key in texstudio.

    Do you have any idea how to define or add a function to open a pdf file under latex mode without switching to PDF mode?


    1. Joachim Artikelautor

      Yes, you can do this, but I would not advise to immediately start fiddling around with macro definitions in TeX. So far I never faced the necessity to implement new macros in AucTeX, as I use a simple trick to get around the close-compile-reopen cycle: for instant preview in PDF mode, I use GSview to display the PDF files. GSview does not lock the files, and so I can compile and immediately get the result in the existing window without reopening. And, even more imporant: without any hacks. Try it!
      So why do you need the latex+dvi+ps+pdf thing in the editor? Why does Postscript not suffice for Preview? Simply use GSview as previewer, it will save you the ps2pdf step while you are working on the document. I would only then convert to PDF when it’s finished.

      1. Wayne

        I have just tried your tricks. It works well! And the sumatra PDF unlocks pdf file as well.

        As I said, I am used to latex+dvi+ps+pdf+pdfviewer routine in texstudio, so I think emacs+auctex can also do that and it’s said that emacs+auctex is highly customizable. If that is possible, I would like to know. But as you suggested, ps is already enough for preview. I think I have to get used to it.

        BTW, I have another question about the preview fuction. As I use psfrag to add some math on the .eps figures, the auctex preview cannot display the modified figures correctly. Is there any trick to avoid this?

        1. Joachim Artikelautor

          Yes, psfrag: since it uses an extra script to replace the strings (at least it did when I last used it some years ago), this behavior is not implemented in the standard preview-latex functionality. If this is a show-stopper for you, you might want to contact the authors via their mailing list and ask about.

  13. Wayne

    I have another question now. Do you know where I can find other useful extensions for auctex, like auto completion and others?

    1. Joachim Artikelautor

      Wayne, I highly advise to read the AucTeX intro. AucTeX comes with all sorts of keyboard shortcuts that are to make your writing faster and are inline with Emacs’ philosophy of editing. There might be experimental branches of Emacs/AucTeX for command completion, but so far I have not seen it.

  14. Wayne

    I am still trying to add a “pdfviewer” command which looks like

    (add-to-list ‘TeX-command-list
    (list “pdfviewer” “sumatraPDF %s.pdf”
    ‘TeX-run-command nil t))

    Emacs can fine sumatraPDF. But it looks that the option %s.pdf is wrong. With that, Emacs tries the command sumatraPDF “filename”.pdf instead of sumatraPDF filename.pdf. With this extra “”, sumatraPDF cannot find the right file name.
    I also tried %o, but in Latex-Mode, %o means filename.dvi by default.
    Maybe you know something that can help me out here. There should be an option that represents filename.pdf. But I have no idea what it is and how to find it.


      1. Wayne

        Thank you for your hints. But those links are not useful.
        Emacs+Auctex is very powerful, but at this stage, it’s very difficult for me to customize it.

  15. Wayne

    Hi Joachim,
    I came across another “little” issue that I cannot find some math symbols in the latex-math mode. Auctex provides a long list of math symbols, but still some symbols are not there. As you know, Winedt as well as Texstudio has a rich math menu. One can probably find the most symbols in those sub-menus.

    How do you find and input extra math symbols in auctex?

  16. chiara

    thanks for the tutorial!I have a problem…I cannot preview a document in pdf. When I try to do it, it says

    ‘pdflatex’ is not recognized as an internal or external command,operable program or batch file.
    Preview-LaTeX exited as expected with code 1 at Tue Jul 24 13:39:11
    LaTeX: LaTeX found no preview images

    I have tried to install everything twice but it didn’t change. Can it have something to do with GSview/Ghostscript or with the EPS printer? Because there I had some problems
    As per the first, I run the installation of GSView after Ghostscript but I could not find the place where to put the program group (and I have no idea where I can find the program group of Ghostscript)
    As per the second, as instructions are in German I have not done it yet.
    Thanks in advance for the help!!

    1. Joachim Artikelautor

      Hey Chiara, did you check whether you can call pdflatex from the command line (Windows Start->Run->”cmd”)? If not, then something with your LaTeX distribution is wrong.

      1. chiara

        Thanks. I went to cmd and wrote “pdflatex” and it says that: ‘pdflatex’ is not recognized as an internal or external command,operable program or batch file.
        I dowloaded and installed the complete version of MikTex 2.9. Shall I install it again? Or do I need to modify something? Or to install the 2.8 version maybe?
        And if I do so, shall I uninstall all the other packages in order to install all in the right sequence?
        Thanks in advance!

        1. Joachim Artikelautor

          It seems that the installer did not add the executables to the search path of your Windows system. Just run the installer again and watch out for something like “add to path”.

          1. chiara

            Hello! Thanks for the suggestion. I re-installed everything again starting with MikTeX and there are some progress…especially, it seems it recognizes pdflatex now. However, I still cannot manage to create a pdf. At first, I thought I didn’t insert the right formatting; so, I dowloaded a template; as it was still not working, I dowloaded the template package for AuCTeX.
            So, I open the document, activate pdf mode and then ask to see the preview. It says to press control-c control-l to see compilation results and below you have what appears.
            Can you help me, please?
            THanks a lot!!!

            Running `Preview-LaTeX’ on `TEMPLATE.tex.tpl’ with “pdflatex “\nonstopmode\nofiles\PassOptionsToPackage{active,tightpage,auctex}{preview}\AtBeginDocument{\ifx\ifPreview\undefined\RequirePackage[displaymath,floats,graphics,textmath,sections,footnotes]{preview}[2004/11/05]\fi}” “\input” “TEMPLATE.tex.tpl.tex””
            This is pdfTeX, Version 3.1415926-2.4-1.40.13 (MiKTeX 2.9)
            entering extended mode
            Babel […] loaded.
            No auxiliary output files.
            ! I can’t find file `TEMPLATE.tex.tpl.tex’.
            …2004/11/05]\fi} \input TEMPLATE.tex.tpl.tex
            Please type another input file name
            ! Emergency stop.
            …2004/11/05]\fi} \input TEMPLATE.tex.tpl.tex

            ! ==> Fatal error occurred, no output PDF file produced!
            Transcript written on texput.log.

            Preview-LaTeX exited as expected with code 1 at Thu Aug 02 13:05:02
            LaTeX: LaTeX found no preview images

          2. Joachim Artikelautor

            Chiara, what are you trying to achieve? And how does the document look like?
            a) You want to compile a document.
            b) You want to get a preview within Emacs.
            c) You have formulas, graphics or symbols in your document.
            What is the template package for AuCTeX? Never heard of this before.

  17. chiara

    Hello Joachim,
    I am so sorry I am asking you so many questions…..
    what I’d like to do with emacs is writing my PhD thesis (with graphs, formulas and references).
    This is the first time I ever use LaTeX, so what I was trying to see was what a .tex doc looks like in pdf (and how to transform it).
    I used a template article(template in the sense that it has already commands like begin/ end document and the various sections)and I wanted to check that I installed everything properly. So I just opened a .tex document and tried to preview it in pdf: first I switched in pdf mode and then asked to preview (C-c C-t C-p, then C-c C-p C-d.). Emacs then asks me to type C-c C-l for results. And then it appears what I copied above.
    Maybe, I am just doing the wrong thing and everything is installed correclty…but I don’t know…
    The template package is Emacs-Template
    Thanks a lot for your patience and help!!!

    1. Joachim Artikelautor

      No problem. Now I understand what you are trying to achieve: You don’t want to create a »preview« as done with C-c C-p C-d, what you want is simply to compile the document. This can be done with C-c C-c, after that, your output PDF will be available for viewing – again C-c C-c.

  18. chiara

    It workkksssssssss!!!!Thaaaaanks!!!!!! With C-c C-c twice it told me that it was an undefined command, but I modified a bit my .emacs (with things that I am not totally understanding yet, but hopefully I will in the future! :) ) and I set .pdf as a default with a .tex
    Thanks again for this wonderful and very useful blog!!!!

  19. Roy Genis

    Ich habe jetzt etwa ein Dutzend Latex-Programme unter Windows 7 installiert. Kein einziges funktioniert. Und dieses hier läßt sich noch nicht mal installieren. Windows 7 ist der letzte Mist. Was unter Windows XP noch ohne Probleme funktioniert, funktioniert unter Windows 7 gar nicht mahr. Es läßt sich überhaupt kein PDF-File mehr generieren. Unter Windows 7 geht gar nichts mehr.

  20. Pingback: Configurar o Latex no Windows « Bianca de Almeida Dantas

  21. Eugen

    Great tutorial! I was able to configure the Emacs+Auctex system thanks to you !
    I wonder how did you figure out so many steps in this installation!

  22. Jason

    I’m having trouble getting the Emacs configuration steps to work correctly.
    I created the .emacs file in my ~\HOME\ directory and then went to “File-> Visit New File”… here I do not see the LaTex, Preview or Ref entries.
    Also, when I added in the step for the (server-start) line, I get a “directory is unsafe” error.
    I attempted to fix the issue using this walkthrough,, but that didn’t work.
    Thirdly, where should I create the Registry Key as mentioned later in the tutorial? (that is, when in regedit, under which directory do I create the new key?)
    Thank you! I’m looking forward to hearing back…

    1. Joachim Schlosser Artikelautor

      So do I understand correctly:
      You edited ~/.emacs and added all the lines? And then, when you edit a .tex file, there are no LaTeX menu entries?
      Could you please check whether you properly did set the HOME environment variable? It seems that this has not taken place, and so Windows assumes c:\
      And that, of course, is an unsafe place.

      On the registry file: if you use the download file, it automatically creates the key at the right spot.

      Does that help?

      1. Jason

        I had to create the ~/.emacs file… and then I “copy-pasted” the code you had listed in to that file.
        As far as the regestry key goes, I’m using Firefox. It opens the file in a new tab when clicking on it… i’ll see if there’s another way to download the file.

          1. Jason

            Yes, I was able to download the registry key and edit it like in step 3.5.
            And yes, the major mode of Emacs is running… but I don’t have the additional options like listed in the AUCTEX + RefTEX section. Those don’t appear in my Emacs menu. The .emacs file is listed in my ~\HOME directory.
            What’s interesting is that even though the .emacs file exists, when first opening Emacs via the Windows start menu and putting in the command C-x C-f, the “Find file:” defaults to something other than the \HOME directory… in this case my “C:\Windows\System32″ directory…

          2. Joachim Schlosser Artikelautor

            We’re making progress. Please open a command window, type
            echo %HOME%
            and see whether it gives you the place you want to. If not, please go to the installation tutorial section on setting up the HOME environment variable.

  23. bob

    I don’t understand how to get the Auctex precompiled package. All links I have found online go to a zip file that contains nothing except a single file, the doc, including this page.

    So confused. :(

  24. Pingback: Getting Started with LaTeX | Over Educated Under Experienced

  25. Jake

    Hi Joachim,

    Thanks for the tutorial. I’m having the same problem as Chiara in the comments above, namely not being able to preview a document and use Preview-LaTeX. I tried using C-c C-p C-d on a sample .tex file which gave me the following:

    Running `Preview-LaTeX’ on `samplefile’ with “latex “\nonstopmode\nofiles\PassOptionsToPackage{active,tightpage,auctex}{preview}\AtBeginDocument{\ifx\ifPreview\undefined\RequirePackage[displaymath,floats,graphics,textmath,sections,footnotes]{preview}[2004/11/05]\fi}” “\input” “samplefile.tex””
    This is pdfTeX, Version 3.1415926-2.5-1.40.14 (TeX Live 2013/W32TeX)
    restricted \write18 enabled.
    entering extended mode
    Babel and hyphenation patterns for 78 languages loaded.
    No auxiliary output files.
    (./samplefile.tex (c:/texlive/2013/texmf-dist/tex/latex/base/article.cls
    Document Class: article 2007/10/19 v1.4h Standard LaTeX document class
    (c:/texlive/2013/texmf-dist/tex/latex/base/size10.clo)) (./samplefile.aux)
    (c:/Program Files (x86)/emacs-24.3/site-lisp/auctex/latex/preview.sty
    (c:/Program Files (x86)/emacs-24.3/site-lisp/auctex/latex/prtightpage.def)
    (c:/Program Files (x86)/emacs-24.3/site-lisp/auctex/latex/prauctex.def
    No auxiliary output files.
    (c:/Program Files (x86)/emacs-24.3/site-lisp/auctex/latex/prauctex.cfg))
    (c:/Program Files (x86)/emacs-24.3/site-lisp/auctex/latex/prfootnotes.def)
    Preview: Fontsize 10pt
    ! Preview: Snippet 1 started.

    l.89 example, $
    2x^3 – 1 = 5$ is typed between dollar signs as
    Preview: Tightpage -32891 -32891 32891 32891
    ! Preview: Snippet 1 ended.(533465+54613×3326398).

    l.89 example, $2x^3 – 1 = 5$
    is typed between dollar signs as
    ! Preview: Snippet 2 started.

    l.91 $
    \lim_{N \to \infty} \sum_{k=1}^N f(t_k) \Delta t$.
    ! Preview: Snippet 2 ended.(642987+196611×6591481).

    (see the transcript file for additional information)
    Output written on samplefile.dvi (4 pages, 2520 bytes).
    Transcript written on samplefile.log.
    Preview-LaTeX exited as expected with code 1 at Mon Jan 6 03:17:54
    LaTeX: LaTeX found no preview images

    I also tried to compile the document as a PDF (instead of previewing) using C-c C-c, which resulted in Emacs saying it is an undefined command.

    One more question: I got zlib1.dll for zlib version 1.2.8 but I can’t find a .dll file for libpng version 1.6.8; do you know where I can find this?

    Thanks in advance for the help!

      1. Jake

        Yes, I checked the FAQ. I tried to check what I was using by running preview on circ.tex. I had some issues though:
        1. I used to download “” which I merged with my emacs folder as you mentioned in your instructions. However, I couldn’t find circ.tex using that zip file.
        2. I went back to to download the zip file which did contain the circ.tex file and opened it on emacs. I ran preview-latex on it by using C-c C-p C-d. It gave me a warning that said there were undefined references and also said

        Preview-LaTeX exited as expected with code 1 at Wed Jan 8 13:32:13
        LaTeX: preview-image-type setting ‘png unsupported by this Emacs

        It outputted a dvi file but when I opened it using TeXLive’s dviout viewer, it didn’t have much on it.

        Sorry, what do you mean by “Does the document compile from command line?”

    1. Joachim Schlosser Artikelautor

      It looks like you were not downloading the correct file, which might have happened because the literature list of this page recently was corrupted. Sorry for that, come back now please, as it is fixed meanwhile.

      1. Jake

        Thanks for all the help Joachim. I wasn’t sure if this guide was supposed to have links or not so I didn’t bring it up.

        I think it’s working now, although I still sometimes get the message : “LaTeX found no preview images”. I think this may be due to something I’m doing, however.

        I have one more question (sorry for all the questions). When I added the Emacs registry file and changed the name of the directory, I still get an error message after double clicking on a .tex file which says “C:\Program Files (x86)\emacs-24.3\bin\emacsclientw.exe: error executing alternate editor ‘C:\Program Files (x86)\emacs-24.3\bin\runemacs.exe'”. This doesn’t happen if I already have Emacs open.

  26. masoud

    tank you very much.
    ihave a qustion:
    what means this error.
    ! Fatal fontspec error: “cannot-use-pdftex”!! The fontspec package requires either XeTeX or LuaTeX to function.!! You must change your typesetting engine to, e.g., “xelatex” or “lualatex”! instead of plain “latex” or “pdflatex”.!! See the fontspec documentation for further information.!! For immediate help type H .!……………………………………….. }

Hinterlasse eine Antwort

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind markiert *

Du kannst folgende HTML-Tags benutzen: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>