Category Archives: Windows

SumatraPDF 0.8 Released

SumatraPDF has just become a very strong contender as an everyday PDF viewer on Windows. The reason: it finally supports searching and bookmarks in version 0.8.

Its interface is still a bit over simplistic, but it’s already quite good for everyday uses. At the moment, the keyboard shortcuts are not very well-documented. Looking at the source code, I noticed some missing entries that are noteworthy:

  • The search interface: / starts a search, so as Ctrl-F. Ctrl-G and F3 is next, and Shift-F3 is previous. Note that the toolbar doesn’t have to be visible for the search keys to work.
  • Ctrl-L toggles full screen mode.
  • F12 toggles the bookmark panel.

(Update: Also note that Ctrl-Drag will select a region and copy its text to clipboard.)

I don’t have a list of the numerous PDF viewers on Windows here: a google search will get you many hits. Personally, I have “switched” to SumatraPDF on my browsers a few months ago, while spending most of my “PDF time” in PDF-XChange Viewer (see this post about its annotation capability).

I still keep Adobe Reader 8 as the default PDF handler: in terms of printing, anti-aliasing and javascript support, I have yet to see any competition to Adobe. However, now that PDF is in the process of becoming an ISO standard and FSF is declaring the GNU PDF project as one of the few high priority projects, hopefully we will see some change in a few years (see this article).

I should note that SumatraPDF 0.8 is still missing hyperlink support. Also, none of Windows PDF viewers seems to support pdfsync (round-tripping between PDF and TeX source). I know the former is being worked on. The latter, hmm…

P.S. Common PDF viewers on Windows also include Ghostview and Foxit Reader.

Switching From Yap to Dviout

(Most recently updated on 2008-02-08, but I have kept the referenced MiKTeX version at 2.5. As far as I know, none of the changes in MiKTeX 2.6 and 2.7 matters to the topic of this post.)

I have recently upgraded my MiKTeX to the latest version 2.5 for some reason. And as much as I love MiKTeX, I have switched from YAP (Yet Another Previewer, the DVI previewer in MiKTeX) to Dviout.

Dviout may not be very familiar to non-Japanese users because, to my understanding, it is primarily developed to deal with Japanese usage (think about fonts). However, it works equally well in English too. I can recommend Dviout over YAP 2.5 for several reasons:

  • Dviout pretty much does everything YAP is capable of: color specials, HyperTeX jumps (you use the hyperref package, don’t you?), and perhaps most importantly, round-tripping using source specials (but see the note below).
  • Unlike YAP 2.5, it does not seem to have any DVI locking issue, at least not in my daily usage of working on a large document. (To me, this alone is worth the switch until YAP eliminates the lock issue.)
  • In my experience, Dviout is much faster than YAP ever since it had a major change in version 2.5. Unlike YAP, Dviout does not make you choose between “dvips” vs “pk font” rendering—the former is slow, and the latter cannot be used when your document has any graphics. There is really no good choice in YAP.
  • The particular document I am working with is also somewhat graphics intensive. Like YAP, Dviout is able to call Ghostscript to show the included graphics in the DVI preview. But it also caches the generated bitmaps and use them later for unmodified figures. This saves me a lot of time. (And this is the primary reason why I expect to stick with Dviout for a while. I sprinkle \parpics and wrapfigures quite liberally on my spaghetti.)
  • Dviout allows you to customize the shortcut keys. I like to exercise my left hand more often and so I set some shortcuts on my left hand.
  • Dviout can do a text search directly inside DVIs. This can be handy if all you have is a DVI file. (Package documentation comes to mind. And yes, you could have converted it to PS and then do the search in the PS…)

(Note: there is an issue that I am still puzzling on. In the forward search, sometimes Dviout will land on a few paragraphs earlier than the intended destination. I will update this post once I figure out the solution.

Update 2007-03-07: Nailed it. First, recall that source specials are implemented by inserting tags that specify the source file and the corresponding line number into the DVI file. The problem is that sometimes the line numbers in the tags are not in increasing order. Here is how the stream of tags might look like: {src:1003main.tex}{src:1055main.tex}{src:1015main.tex}{src:1019main.tex}. In this case, if you ask the DVI previewer to go to line 1015 of main.tex, a simple scan algorithm will hit the second tag and then incorrectly conclude that no further reading is necessary. This is exactly what happened. Workaround? I guess I will have to wait until I finish my current project and patch the source directly.)

Below I will show how to get Dviout working with MiKTeX 2.5. (Update 2007-11-15: The same instruction works for MiKTeX 2.6 because there is no change in directory layout.)

  1. Remove the directory C:\localtexmf\fonts if you have one. It contains your existing PK font files. We can afford to regenerate them. MiKTeX 2.5 by default put PK files in a different location too.
  2. Create a new file dviout.par and put it in the same directory with dviout.exe. It’s the preference file for Dviout.
  3. I have included the non-default parameters that I use at the end of this post. You can use it as your first dviout.par and start from there. As you can see, there are some hard-coded path names that you will need to change. The following is a list of parameters that you want to pay attention to, in the order of appearance in my dviout.par below:
    This means “On” with “Direct PS” turned off in the Graphic tab. Keeping Direct PS off can mitigate a class of problems due to dvi files prepared with source specials containing postscript. For instance, you can generate such a dvi file by using hyperref with the dvips driver, which is usually the default. The right driver for dviout is hypertex, used like this \usepackage[hypertex]{hyperref}.
    You may have installed Ghostscript somewhere else. I note that MiKTeX comes with Ghoscript these days, but I usually keep an installation of the most recent Ghoscript so I don’t use the one that comes with MiKTeX.
    All my documents store their figures in a figure subdirectory. The current setting tells Dviout to cache the preview bitmaps in the same subdirectory instead of the parent directory where the DVI is located.
    I installed my MiKTeX there. The default for 2.7 would be `C:\Progra~1\miktex~1.7\bin\makepk.exe ^s ^d ^D ^M. There should be no space in the path name and so you must use short path. Also, be careful with the backquote character.
    I have added four shortcut keys to my config. “z” and “x” are for back and forward, “-” and “=” are for zooming out and in. Also, note that “space” is by default mapped to next-page, and so the pair “z” and “space” is all I use most of the time. Remember, the shortcuts are fully configurable in the Option->Set Parameter->Key tab.
    BMP and scale
    I have made an unusual choice here because of my late-night TeXing. The negative numbers represent negative gamma, which is to say that the DVI text is displayed in white on black. If you want the normal black on white, change the -400 to 1100. The particular number depends largely on the font you use and your monitor, but 1100 is in the ball park. (This answers rmcd’s comment.)
    For MiKTeX 2.6, the current setting is a sensible choice. This is what ^r in the TEXPK option expands into.
    If you have installed MiKTeX 2.6 at its default destination, use TEXPK=”^r\fonts\pk\\dpi^d\^;C:\Program Files\MiKTeX 2.6\fonts\vf\\^s.vf” instead. You can read my comment on 2007-03-23 to understand what it does and how you can come up with the right setting for your machine with the help of YAP.
    According to the Dviout manual, this option is needed when you cannot generate a PK font but you want to replace the missing characters with spaces of the correct size, hence the need to locate the TFM (font metric) files. I would say that if you cannot generate an English PK font, then you want to resolve the issue completely instead of relying on this feature.
    I use GNU Emacs on Windows since a long time ago and I am still at version 21. That explains why I picked gnuclientw as my src editor. In the comments, rmcd explained how to use emacsclient instead. Dviout supports DDE as well and so you can use many other editors. See the help file for instructions.
    I use Ipe for most of my graphics. That explains the path in gsrc.
    With the GS option above, we have turned off Direct PS. This “ignore some source specials” setting further suppresses a whole bunch of (mostly harmless) warnings. There are pros and cons, but I think this together with the GS setting above is a sensible default.
    This is where you put dviout.par. Of course, you don’t really change this setting by changing it inside dviout.par, but this is a non-default setting with a hardcoded path. :P
  4. Finally, to make AUCTeX use Dviout instead of YAP, here is a snip from my tex-site.el. Note that I am showing you Emacs Lisp here and as rmcd pointed out in his comment, you do not want to enter the backslashes before the two inner double-quotes if you are using Emacs’s customize-variable command to change your TeX-view-style. The backslashes are only necessary in Emacs Lisp so that we escape the two inner double-quotes.

    (setq TeX-view-style
    '(("^a5$" "yap %d -paper a5")
    ("^landscape$" "yap %d -paper a4r -s 4")
    ("^epsf$" "gsview32 %f")
    ;;("." "yap -1 -s%n%b %d")
    ("." "dviout -1 %d \"# %n %b\"")))

Here are some usage tips on Dviout:

  • As much as I prefer not to ask you to touch the registry, you want to know that Dviout remembers some of its settings in HKCU\Software\SHIMA\DVIOUT. For instance, it stores the window dimensions there. (I set my xPos, yPos, Height and Width in the registry once and for all.) I believe that all options set outside of Option->Set Parameters, such as Option->Continuous Renew, are stored in the registry.
  • You may also want to disable Options->Check color specials from the menu in case Dviout complains about your DVI file. It happens when your color specials have certain issues as explained in the manual. I meet these issues too frequently.
  • Make sure you enable Options->Setup Parameters...->System->Auto Renew. (It’s on by default, but it’s worth checking in case you turned it off by accident.) It forces a update check when you switch into Dviout from another application. This behavior is shared among most, if not all, DVI previewers.
  • Options->Continuous Renew is a good thing if you have a large monitor or a dual monitor to let you see both your text editor and Dviout without overlap. This option will cause Dviout to pop into foreground when the DVI file is updated. Using Microsoft’s Tweak UI, in General->Focus, enable Prevent applications from stealing focus and set it to flash the taskbar button one time. That will make Dviout always show you the latest DVI without stealing the focus from your text editor. (I use this with the continuous mode in latexmk.)
  • Most importantly, once you have customized the options using Option->Setup Parameters to your own liking, select Option->Non-default Parameters. A small text box will pop up and you can copy and paste its content into your dviout.par. (That’s how I get the file below.)

Have fun with Dviout!

Finally here is my current dviout.par (last updated 2008-02-08). I have also uploaded it as a file to avoid line wrapping and other funny things due to quotes.

gen="`C:\texmf\miktex\bin\makepk.exe ^s ^d ^D ^M"
TEXROOT="C:\Documents and Settings\All Users\Application Data\MiKTeX\2.6"
src='gnuclientw^s+%d "%s"'

P.S. I should mention that staying with MiKTeX 2.4 would not be a bad choice if I could… You should also be reminded of potential issues if you decide to upgrade to Vista before MiKTeX 2.6 comes out.

Two Patches for X41 Tablet

Recently I have finally switched to a ThinkPad X41 Tablet for my everyday computing need. I said “finally” because I actually had the machine since more than a year ago (Sept 2005), but it had more than a couple issues that kept me from relying on it solely. I remember being asked on a trip why I brought two laptops along. :P

The good news is that Microsoft has fixed two of my issues over the summer. If you are using a X41 tablet as well (already there are five in my group), here they are:

  • Insufficient System Resources Exist to Complete the API during hibernation: hot fix 909095
  • The mouse pointer or pen pointer behavior is irregular in Windows XP Tablet PC Edition 2005: hot fix 920295

The latter is particularly important since it makes the tablet a lot more responsive when the CPU is under load. I can’t imagine how I could have lived with a “jumpy” cursor for over a year…

Now if only someone makes a fast and reliable 1.8″ harddrive…


In the past, I used to manually set up the tool chain for PDF production on Windows.

Basically, this requires the installation of Ghostscript and a PS printer driver that prints to a RedMon port. The trick is to configure the PS printer driver so that it embeds Type 42 fonts. And I also need to have pdftk to set the document security and then stuff…

Well, that was indeed the past. :P These days I get lazy and just use the free (as in beer) product PrimoPDF. So far, I find it does everything right, but I still manually remove the Ghostscript 8.50 that is bundled in its installer (remove the gs subdirectory) and let it use the most current version on my computer.

Combined with the ability to split and join PDFs using pdftk, that’s a pretty good basic setup for everyday PDF production at a low low cost of zero dollars. I am all thankful!

Update: Many of you reminded me that I should really mention PDFCreator in this post as well. I agree. Both of them are great!

Explorer Here

Command Prompt Here seems to be a well-known feature among the Windows users. It lets you right-click on a folder and open a command prompt with the current working directory set to that folder.

But what about its “functional inverse”, i.e., start an explorer to explore the current directory? Well, you can execute explorer . in the Command Prompt, but that will not be exactly “correct” since the tree view of folders is missing. Apparently you have to add a completely obscure argument… I put this command in a batch file on my path:

start "" explorer /e, .

Note that there cannot be a space between the “e” and the comma. Don’t ask.

List of Keyboard Shortcuts in Windows XP

A couple days ago a pretty savvy Windows user in our Theory group asked me if there is any keyboard shortcut to rename a file in Explorer. I don’t know how I learned about it, but F2 is the answer. It seems to have dated back to my Lotus 123 days. In Lotus 123, F2 means “edit cell” and it also works in Excel for the obvious reason. I also notice that Microsoft actually publishes a list in their knowledge base:;en-us;Q301583

Well, but this list is surely not comprehensive. For one thing, I note that Ctrl+Shift+Esc is not listed anywhere. (This brings up the Task Manager.)

Command Line Mute

Your laptop just makes the familiar “oh-oh” sound. You know you have an instant message in ICQ.

The problem is, it’s 5:30 in the morning right now… Indeed you forgot to turn off your speaker the night before.

It doesn’t have to be like this.

The one last time this happened to me, I decided to fix this problem once and for all. So I wrote a command line utility that lets me mute and un-mute my computer speaker. Couple this with the Task Scheduler in Windows, my laptop knows when to keep quiet. :)

Usage: cmdmute [0|1]
0 - Mute OFF
1 - Mute ON
Toggle if no argument is given.

Update on 2007-01-30: Source posted. Compile it with cl cmdmute.cpp winmm.lib

Update on 2008-11-11: I use this only on Windows XP and I don’t have Vista for testing.

Update on 2008-12-23: I heard that nircmd works on Windows Vista.

pdfopen and pdfclose

Update on 2008-01-24:
The “back” feature is no longer needed, at least on Windows Acrobat Reader 8. See: Edit->Preferences->Documents->Restore last view settings when reopening documents

Update on 2007-01-30:
I have patched the source and replaced the zip files so that pdfclose will be less likely to crash Adobe Reader 8. Thanks to this post. Also, apparently pdfopen cannot issue a “back” command to Adobe Reader and you need the full version for that feature.

If you are a Windows user and use Acrobat or Adobe Reader(*) to view PDF files, you may have experienced Acrobat locking your PDF file, making it impossible to overwrite. This is a serious problem when previewing your paper in the PDF format because every time before you generate a new PDF, you need to remember closing the old PDF in Acrobat.

Part of my solution to this problem is to open the PDF using pdfopen:

pdfopen --file foo.pdf

This will allow me to close foo.pdf by:

pdfclose --file foo.pdf

Integrating these two commands into your work-flow is left as an exercise to the reader. :)

But there is still an important usability problem that these two commands won’t solve. Every time you re-open a PDF, you will not be on the same page when you closed it. Instead, you will be on the first page. How would I to fix this? One solution would be to press Alt-Left after I re-opened the PDF file. This goes back in history and brings me to the last view I was at. But I’ve got something better.

I’ve modified the source code of pdfopen from TUG to include an extra option --back to do the obvious thing. So instead of the above, you should open a PDF file by:

pdfopen --file foo.pdf --back

Now the cycle is complete. Phew!

I have posted the exe files in a zip. The source files are available too.

For the record, you can obtain the original pdfopen and pdfclose at this URL:

BTW, I’ve read that recent versions of TeXnicCenter and WinEdt can both perform this Acrobat cycle too. But I am not sure if they can go back to the previous view. Heh, surely I know my Emacs can. :P

P.S. I am also aware that you can use gsview32 to preview PDFs and gsview32 does not lock PDF files. That’s one way to avoid this problem.

(*) Really, it’s called Adobe Reader. I don’t know since when they dropped the middle word.

CLCL – The Clipboard Manager

Those of us that use Microsoft Office should be familiar with the concept of a clipboard manager (since it has one built-in for the Office applications). Basically, a clipboard manager lets you maintain a history of your clipboard contents.

Say you want to copy a number of objects from several different slides to a new slide. Without a clipboard manager, you copy the objects from the first source slide, then you go to the destination slide, paste the clipboard content onto it, and then you repeat by going to the second source slide. Notice that you need to keep going back and forth to the destination slide because your clipboard content will be overwritten by a subsequent copy command. See how a clipboard manager can help?

But what if you are not working in an Office application? Well, that’s what CLCL is for. It’s a free clipboard manager for Windows and works for all applications.

But in my experience the single most important feature of CLCL turns out to be its ability to beep when you copy something to the clipboard. I love this audio feedback because some applications (Firefox in particular) seem to have trouble copying things. I don’t want to wait till I paste to realize that the copy did not happen. For this feature alone, I happily keep CLCL running all the time. :P

To enable this audio feedback, download the tool_utl plugin from CLCL’s homepage. Then go to Options->Tool->Add. The DLL you want is tool_utl.dll and the function name is play_sound. Then click Properties and go to the Windows\Media directory to select your favorite wave file. I use windows xp pop-up blocked.wav.

P.S. I was told that in Mac there is actually an visual feedback to indicate that the copy (Command-C) was successful. Specifically, the Edit menu item will blink once. But there is a problem. It blinks so fast that it is hard to spot. So what some users end up doing is to hold down Command-C to repeat the blinking (basically turning Edit into reverse video). Heh, I guess we all have our problems.

Sysinternals PsTools

PsTools from Sysinternals is a collection of command line utilities that let you manipulate processes in Windows. Among the tools, I personally use pslist and pskill every single day(*). Check it out!

And if you have pslist, then put the following into a batch file, say mlist.bat. It’s very handy for nailing down memory leaks. (Note that the @ sign in the front of a command in a batch file suppresses the echoing of the command. That’s why many batch files start with @echo off.)

@pslist | sort -n +5 | tail -n 10

BTW, with the release of Windows XP and Windows Server 2003, Microsoft has bundled two command line tools that do similar things (tasklist and taskkill). However, their command line interface is awkward. I recommend you forget about them and stick with PsTools.

(*) largely because of Firefox and Acrobat


Many small annoyances of Windows are due to unreasonable default settings. For example, the dir command in the command prompt (cmd.exe) does not sort its output by default. Can you believe that this is year 2005?

I know, I know. It’s more convenient for the programmer to just dump the content from the master file allocation table, but we should focus on the user’s experience. And indeed sometimes a directory may be so huge that sorting the files would take seconds, but how many of the normal users would encounter such a directory?

In the end, I believe we all want to the output of dir to be sorted. The solution is to set the DIRCMD environment variable to /o, meaning that you want it to be sorted. (I myself also use /a, meaning show all files.) On the one occasion that you hit a huge directory and don’t want the output to be sorted, you can use dir /o- to disable it just for once.

Sysinternals Junction

On average, I get asked the following question about once a month:

Are there symbolic links in Windows, similar to the ln -s target_name link_name on Unix?

Let me answer it here once(*) and for all. The answer is “yes”. NTFS supports a similar concept called junctions. Sysinternals even has a free utility for you to manipulate junctions.

To create a junction, say junction link_name target_name.

(*) although in reality I don’t expect most that will ask me such questions to read this blog…

Windows Command Line – Shortcut Key

Even though I am a Windows user, I spend a lot of time in the command prompt. While many Unix users actually tweak their .login and related files, I’ve seen a lot of Windows users living with the default. This series proposes several easy fixes to make their life easier.

First thing first: the command prompt that all of us should be using on Windows NT or later is cmd.exe whereas is there only for backward compatibility…

I recommend associating a hotkey to your command prompt. I use Ctrl-Alt-Z to mimic the Ctrl-Z feeling in Unix.

Many Windows users miss this feature. For each shortcut in your Start menu, you can associate a hotkey with it. Right click on Start->Programs->Accessories->Command Prompt. Click Properties.

Command Prompt Hotkey

Click on the text field of Shortcut key and press Ctrl-Alt-Z. Then click OK.

Now no matter where you are, pressing Ctrl-Alt-Z will get you to the command prompt.

P.S. There is an annoying “feature”. If you have opened a command prompt already, it will bring you there instead of opening a new one. I will tell you how to fix it later.

Quick Zooming in PowerPoint

Do you know that you can quickly zoom in PowerPoint by using the scroll wheel while holding down Ctrl?

P.S. In fact, this behavior seems quite consistent among many Windows applications, including non-Microsoft applications like FireFox. I suppose Office started the trend and now it gets into the human interface guideline?

Keyboard Shortcut to Task Manager

You probably know you can launch the Task Manager by right-clicking on the Task Bar and then click on the Task Manager on the context menu. But do you know it can also be done by pressing Ctrl-Shift-Esc, directly from within any Windows application?

Along the same line, Ctrl-Esc will bring up the Start Menu. Followed by R, you can get to the Run dialog box in three keystrokes. (On a keyboard with a Windows key, it’s possible with just two keystrokes. But that’s a later story.)