Setting up text-editors for MiKTeX
(a LaTeX implementation on Windows)
Get
MiKTeX
at http://www.miktex.org/.
At the time of this writing, I used MiKTeX 2.4.

Run this installer, accepting all of the defaults.
When completed, you should find these Start Menu entries.
To use MiKTeX, one would then use a text-editor to compose your TeX/LaTeX source,
e.g. my_next_opus.tex.
One would then open a command shell ( Start Menu --> Run --> cmd ),
navigate to the source directory (using cd "PATH_TO_YOUR_DIRECTORY"),
then run
(assuming that MikTeX was installed in C:\texmf\)
C:\texmf\miktex\bin\latex.exe my_next_opus.tex
If any paths or filenames contain spaces (or to be extra careful), one must enclose each object in quotes, e.g.:
"C:\texmf\miktex\bin\latex.exe" "my_next_opus.tex"
Then, to view the resulting .dvi file (exercising extra care):
"C:\texmf\miktex\bin\yap.exe" "my_next_opus.dvi"
Other MikTeX commands (like dvips, dvipdf, etc...) are available in C:\texmf\miktex\bin\
Since the use of the command shell is tedious,
I will describe the setup on two text-editors
(focusing on the features below in bold red).
I'm certain that other text-editors can be analogously configured.
"Notepad++
is a free source code editor (and Notepad replacement) which supports several programming languages running under the MS Windows environment."
Some nice features:
- Open source (GPL).
- Syntax highlighting (for multiple languages), Code Folding, Plugins.
- Ability to be started at a specified line-number... so that clicking on a DVI-file viewed in YAP can be directed to the corresponding line in the TeX-file.
If you want to use Notepad++,
visit http://notepad-plus.sourceforge.net/,
obtain and run this installer, accepting all of the defaults.
Then, continue with this link:
setup Notepad++.
"UltraEdit
the #1 selling, most powerful, value priced text editor available!
UltraEdit-32 is a disk-based editor for Windows 98/Me/NT/2000/2003 and XP (not Win32s)."
Some nice features:
- Syntax highlighting (for multiple languages), Code Folding, Tags... for templates.
- Column-based editing.
- FTP and secure-FTP support.
- Ability to be started at a specified line-number... so that clicking on a DVI-file viewed in YAP can be directed to the corresponding line in the TeX-file.
- Ability to pass a line number to YAP... so that YAP can view the corresponding section in the DVI-file. (It may be possible
to write a Notepad++ plugin that does this. This is possible in Notepad++ without a fancy plugin, thanks to Kunle Adegoke.
See below.)
If you want to use UltraEdit,
visit http://www.ultraedit.com/,
obtain and run this installer, accepting all of the defaults.
Then, continue with this link:
setup UltraEdit..
SET UP Syntax Highlighting in Notepad++
Compose (by typing or copy-pasting) this short LaTeX file.
\documentclass{article}
\begin{document}
Since $ax^2+bx+c=0$, we have $x=\frac{-b \pm \sqrt{b^2-4ac}}{2a}$.
\end{document}
|

and save it as my_next_opus.tex.
Note that Notepad++ now recognizes it as a .tex file and does syntax highlighting.
Unfortunately, I find the underlined text annoying.
So, select Settings --> Styler Configurator...

and locate TeX and TEXT and uncheck
Underline.

SET UP MikTeX's latex command in Notepad++
Select the Notepad++ menu-item Run and type exactly (or copy-paste)
|
"C:\texmf\miktex\bin\latex.exe" -src-specials "$(FULL_CURRENT_PATH)"
|
-src-specials instructs latex.exe to embed extra information in the .dvi file for yap's inverse-search feature.
"$(FULL_CURRENT_PATH)" is the quoted full-path passed by Notepad++.

You can test it out by clicking the
Run button.
To make it a permanent entry in the Run menu,
click the Save... button.
Enter a name (say LaTeX)
and choose a keyboard-shortcut (say Alt-S)

It is now added to the Run menu.

SET UP MikTeX's yap command in Notepad++
Do the same for YAP (MikTeX's .dvi viewer).
Select Run and type exactly (or copy-paste)
|
"C:\texmf\miktex\bin\yap.exe" -1 "$(CURRENT_DIRECTORY)\$(NAME_PART).dvi"
|
(suggested by Kunle Adegoke (16 July 2008))
"C:\texmf\miktex\bin\yap.exe" -1 -s $(CURRENT_LINE)$(FILE_NAME) $(NAME_PART)
|
This provides the forward-search feature so that
YAP can view the corresponding section in the DVI-file.

To make it a permanent entry in the Run menu,
click the Save... button.
Enter a name (say YAP)
and choose a keyboard-shortcut (say Alt-D)

-1 tells yap to have only one instance.
"$(CURRENT_DIRECTORY)\$(NAME_PART).dvi" is the quoted full-path of the .dvi-file passed by Notepad++.
-
The last step is to configure yap's inverse-search so that clicking on a section in the .dvi-file
opens the corresponding line in the .tex-file in Notepad++.
Start yap by clicking on Notepad++ menu-item Run --> YAP
or by double-clicking on the .dvi file.

Once yap has started, select menu-item View --> Options...

Type exactly or copy-paste into the command-line field:
|
"C:\Program Files\Notepad++\notepad++.exe" -n%l "%f"
|

Now, when clicking on a page in a .dvi-file, the Notepad++ editor opens the .tex-source
at the corresponding line number.
Manually editing the Run menu in Notepad++
It's possible that you made an error and may wish to change some settings in the Run menu.
You manually edit your version of
"C:\Documents and Settings\rsalgado\Application Data\Notepad++\shortcuts.xml"
Opening .tex files in Notepad++
Notepad++ adds an "Open in Notepad++" menu-item when right-clicking on any file.
However, Notepad++ may not be the default application that is started when simply double-clicking the .tex file.
You can customize the default behavior in Windows by selecting the "Open" menu-item for the first time,
then navigating to the application you wish to use as the default. Alternatively, you can tell Notepad++ to make
itself the default by clicking on Notepad++ menu-item
Settings --> Preference... --> File Association --> fortran, TeX, SQL --> .tex --> "->"-button

UltraEdit can do all of the features we've discussed for Notepad++ above,
plus one more feature: opening yap to the section in the .dvi-file corresponding
to the text-editor's current line in the .tex-file.
It's possible that Notepad++ can do this as well. If so, please let me know.
-
SET UP Syntax Highlighting in UltraEdit
Compose (by typing or copy-pasting) this short LaTeX file.
\documentclass{article}
\begin{document}
Since $ax^2+bx+c=0$, we have $x=\frac{-b \pm \sqrt{b^2-4ac}}{2a}$.
\end{document}
|
and save it as my_next_opus.tex.
Unlike Notepad++, UltraEdit does not recognize it as a .tex file and
does not do syntax highlighting... yet.
By choosing the menu-item
View --> View As...,
note that TeX/LaTeX is not among the languages recognized in the included WORDFILE.TXT.
However, you can visit this
list of UltraEdit wordlists that could be included in
"C:\Program Files\IDM Computer Solutions\UltraEdit-32\WORDFILE.TXT"
You can access the WORDFILE.TXT file
and customize the colors by the UltraEdit
menu item
Advanced --> Configuration... --> Editor Display --> Syntax Highlighting
-
SET UP MikTeX's latex in UltraEdit
Select the UltraEdit menu-item
Advanced --> Tool Configuration....
Click Insert, then give a name to the tool
(say, LaTeX).
-
Type exactly (or copy-paste) into the Command Line:
|
"C:\texmf\miktex\bin\latex.exe" -src-specials "%f"
|
-src-specials instructs latex.exe to embed extra information in the .dvi file for yap's inverse-search feature.
"%f" is the quoted full-path passed by UltraEdit.
-
Type exactly (or copy-paste) into the Working Directory:
(Naively, I thought that "%p" would work... but it doesn't. Use %P (no quotes!).)

Select the tab Options,
and make sure that Dos Program is selected
and that Save Active File is checked.

Select the tab Output,
and make sure that Output to List Box is selected
and that Show DOS Box and Capture Output are checked.
Click OK.

-
SET UP MikTeX's yap in UltraEdit
Do the same for YAP (MikTeX's .dvi viewer).
Select the dashed-line, click Insert, then give a name to the tool
(say, YAP).

-
Type exactly (or copy-paste) into the Command Line:
|
"C:\texmf\miktex\bin\yap.exe" -1 -s %line%"%n.tex" "%n.dvi"
|
-1 tells yap to have only one instance.
-s %line%"%n.tex" specifies current-line in the .tex-file to be passed to yap by UltraEdit.
This tells yap to view the corresponding section in the .dvi-file!
*If this doesn't work for you, continue on and finish the setup. Then consult the "Alternative UltraEdit setup" section at the end of this document..
"%n.dvi" specifies the .dvi-file.
-
Type exactly (or copy-paste) into the Working Directory:
(Naively, I thought that "%p" would work... but it doesn't. Use %P (no quotes!).)

Select the tab Options,
and make sure that Windows Program is selected.

Select the tab Output,
and make sure that
Show DOS Box
and Capture Output are UNchecked.
Click OK.

You assign a keyboard-shortcut by
selecting the menu-item Advanced --> Configuration... --> Key Mapping.
Locate AdvancedUserTool1.
Enter the desired new keystroke, say, Alt-S for LaTeX,
then click Assign.
Repeat for AdvancedUserTool2. Use, say, Alt-D for YAP.

Opening .tex files in UltraEdit
UltraEdit adds an "UltraEdit-32" menu-item when right-clicking on any file.
However, UltraEdit may not be the default application that is started when simply double-clicking the .tex file.
You can customize the default behavior in Windows by selecting the "Open" menu-item for the first time,
then navigating to the application you wish to use as the default. Alternatively, you can tell UltraEdit to make
itself the default by clicking on UltraEdit menu-item
Advanced --> Configuration... --> File Associations
then following the directions.

Alternative UltraEdit setup
Although I think I used the documented commands correctly,
the ability to pass a line number to YAP...
so that YAP can view the corresponding section in the DVI-file
may not work, as described above. What does seem to work is this alternate setup.
- In the Tool Configuration setup, in place of
|
"C:\texmf\miktex\bin\latex.exe" -src-specials "%f"
|
use
|
"C:\texmf\miktex\bin\latex.bat" "%n"
|
(This won't work until we provide the batch file latex.bat.)
- In UltraEdit,
compose (by typing or copy-pasting) a new file:
@echo off
C:\texmf\miktex\bin\latex.exe -src-specials "%1.tex"
|
Now, using File --> Save As...,
save this file as C:\texmf\miktex\bin\latex.bat
[In the alternative command from UltraEdit,
the filename (without its path or extension) is passed
to the batch file. The batch file then calls the latex.exe command.
I'm not sure why this seems to work.]
The use of the batch file allows more commands to be executed.
Here's is a slightly more advanced batch file:
@echo off
C:\texmf\miktex\bin\latex.exe -src-specials "%1.tex"
C:\texmf\miktex\bin\bibtex.exe "%1"
C:\texmf\miktex\bin\SENDMSG /CLASS "MikTeX_yap" WM_COMMAND 44040 393808
|
Here bibtex is called as well.
The last line needs some explanation.
It appears that YAP (v2.4.1803) doesn't not correctly refresh itself when the currently viewed .dvi file is changed (after latex.exe is run).
So, I found a free utility called SendMsg 2.1 (Maximum Output Software)
which can tell YAP to refresh itself. From the SendMsg.zip file obtained from their website,
I extracted the SendMsg.exe program into C:\texmf\miktex\bin\ folder.
Rob Salgado (salgado@physics.syr.edu)
version 6/26/2006 of http://physics.syr.edu/~salgado/software/latex/miktex_setup/
(zipped)