[HOME]
[RESEARCH]
[TEACHING]
[PUBLICATIONS]
[COMPUTING]
[STUFF]
[CV]
[LINKS]

Gregor's Computer Tips & Tricks

Computer knowledge is only temporary and many things are quickly forgotten. This is a necessarily outdated list of things I'm trying to remember about applications, operating systems, programming and hardware. Part of it may be obsolete or even wrong, so there's no guarantee that anything will work.

Most of the things will refer to specific installations and my local computer and network background.

If you have questions, you can try to email me at but don't expect an answer.
 

TeX on PCs

My favourite TeX-implementation for Windows is MikTeX by Christian Schenk. Christian has done a terrific job in implementing a TeX-System in native Windows 32-bit code. You can obtain MikTeX from any CTAN archive e. g. on ftp.dante.de/pub/tex/systems/win32/miktex/ . You will find an exe file that will perform the installation of the complete TeX-system for you, which was a tedious task before MikTeX was available. The only thing you might have to do is to decide whether you want to have an additional TeX-Path (TeXMF-Tree) where you can store your personal style-files, fonts, and LaTeX-packages apart from the original TeX-Path so that future upgrades are not adversely affected by your custom files. Life is getting better and better: MikTeX can now (2004) download missing packages on the fly.

To use MikTeX - and for a lot of other purposes my favourite Editor - is WinEdt (not to be mixed up with WinEdit!) by Alexander Simonic. WinEdt is probably the most powerful Editor for Windows that can still be used by non-experts as well. Most importantly you can instantly use it together with MikTeX, Yap, and GhostView. Download WinEdt from CTAN as well and register it right away, it is really worth the few dollars.

 

Thesis & scientific writing

A few comments on MS-Word

To typeset my diploma (Master's) thesis I used MS-Word 6.0 and most of what I'm saying applies to all the newer versions of MS Word as well. Everyone trying to write their thesis with this sort of program should try to think about whether they need more than ten or twenty formulas in their work and whether it is going to be more than hundred pages or not. If at least one of the two criteria applies, I'd strongly recommend TeX as a freely available alternative. For all other purposes MS-Word will do, although you have to keep a few things in mind before you start:

  • The master- and subdocument mechanism does not work properly in MS-Word, although you can try if you have really strong nerves.
  • Devise a template for every type of paragraph you write be sure that every kind of text has its proper template assigned.
  • Try to keep the style-templates only in your document template or only in your document. Otherwise you might get a horrible mix of the both.
  • Every figure that you include should be linked only. Do not store them in your document. Avoid embedded objects, if you are running your system on something slower than a CRAY supercomputer.
  • Work in "Draft" view only and try to switch to "Layout" as little as possible.
  • Give every cross-reference to figures or other parts of text a proper name. (Word will issue some random number starting with "Ref..." which is impossible to identify when Word has forgotten its target or you have deleted it.)
  • Do the TOC after you are really finished with writing and most of the layout.
  • Never try to print different parts on different computers or printers. The probability that the two will match is zero.
  • In c't 20/1998 they have still more tips. A very good source is also the Microsoft Valued Professionals' website.

TeX

I'm using the KoMa-Script class scrreprt which is already included with the default MiKTeX installation. There are a few nice LaTeX-packages which are pretty useful in this context.

  • float has better handling of floating environments as e.g. tables and figures than standard LaTeX. It introduces a different meaning to the modifier [h] which then really means "put it here", which is not ture for standard LaTeX.
  • wrapfig is in my opinion the best of all packages to typeset inline figures (figures which are not a full column or page wide and have text running around). It does a pretty good job if you resist the temptation to put such a figure close to a sectioning command. Doing so will result in misbehaviour of LaTeX until it encounters the next higher sectioning command.
  • caption2 gives you more flexibility to typeset figure captions, which is especially important for inline figures (very narrow space).
  • footmisc does similar things for footnotes, including the ability of per page numbering of footnotes.
  • graphicx is by now probably the standard package for graphics file incusion into LaTeX.

WBibDB is a very useful Windows tool to manage BibTeX-Database files. It is copyrighted but currently freely available. I added a LaTeX-style hyperlink feature (interpreted as "run" excuting "acrobat #1") so that I'm able to launch Acrobat/Reader directly from within my literature database showing the current entry (if i have it). WBibDB could use a little face lift by now, I am afraid it is not really being maintained. An Interface to the big databases (SciSearch, Inspec, etc.) or the Physical Review would be so helpful. Nowadays, though, the AIP journals can be accessed through Scitation and in there, references can be exported to BibTeX (same for Science). I would even consider to work on it myself but porting the Borland Pascal source code to 32-bit Delphi seems more work than I can afford to invest.

I found over time that way too few researchers enjoy the real power of BibTeX. Often I see that people enter all references by hand into their various papers, theses, etc. What a waste of time! My personal literature database, which is a file originally started by Thomas Herzog then continued by Michael Reck before I put my hands on it, has about a thousand entries. (I wish I had thoroughly read all of them).

Related to BibTeX it is worth to mention the bibentry package, which allows to get the full citation text inserted into the main text. A somewhat related problem is our frequent use of commented references or even footnotes mixed into the bibliography. I haven't seen a clean LaTeX/BibTeX solution for this problem.

TeX and Figures

EPS-figures can be included into TeX documents very smoothly. If you have all the latest versions of pdftex and graphicx you can even leave out the extension for the figure file you are specifying in say

\includegraphics{myfigure} instead of \includegraphics{myfigure.eps}

and if you compile your document with LaTeX it will look for .eps figures, whereas pdfTeX will look for .pdf. PDF is much more useful nowadays, especially because it is possible to achieve very small file sizes, suitable for email transmission and web viewing. A pdf document for screen viewing will typically be 10 times smaller than the equivalent PostScript file.

TeX and PostScript fonts

I have invested a lot of work to get additional Postscript Fonts to work with TeX. In particular I got Bitstream's Cheltenham and Humanist521 to work with my personal thesis style. If you want to do something similar, you first have to own the fonts, I mean the *.pfb files (+ *.afm). And you will need a few utilities, e.g. the fontinst-package.

With modern TeX installations it seems possible that one use TrueType fonts (the Windows standard) to typeset TeX documents, so you may want to check this out.  

Including Publication Reprints

For many people it happens that they want to put reprints of publications related to their thesis into the document. I think these pages should be counted but not numbered as this would interfere with the reprint. The best method I found (That applies to documents that are available as PDF or PS probably also MS-Word and others.) is to create from the orignal document e.g. a downloaded PDF-File one EPS-File per page. (1. I think it is impossible to insert into a TeX-document something that has more than one page?! 2. I found it difficult to create an EPS-File from pure text (e.g. from WinEdt or notepad). No matter what I did, it always came out as PostScript which cannot be included into a TeX document. Workaround: If you have Acrobat Exchange installed then create a PDF and the EPSs therefrom.) You will then probably find that the bounding box of this document is too large to fit LaTeX's \textheight and \textwidth. So you just have to adjust the bounding box in the EPS-File accordingly (1 PS point is approximately 0.35mm) and turn off the clipping at the graphics inclusion command (e.g. \includegraphics[clip=false]{prlpage.eps}) I also recommend that you issue \thispagestyle{empty} to keep headings and pagenumbers from being printed. If you are using the twoside option and the preprint sticks out of the normal textarea you have to avoid that the preprint touches the paper margin. The following code will try to align the figure appropriately. (You have to include \usepackage{ifthen} for that):


\begin{figure}
\ifthenelse{\isodd{\value{page}}}
{
\begin{flushright}
\includegraphics[clip=false]{prlpage.eps}
\end{flushright}
}
{
\begin{flushleft}
\includegraphics[clip=false]{prlpage.eps}
\end{flushleft}
}
\end{figure}

        

Further to what I said here, if you don't need the Postscript (and who does?) now there is an unbelievable package called pdfpages that does everything for you and even more.

Additional Lists (like list of figures)

can be created easily using the tocloft package. For example, a list of reprints is created by:

\newcommand{\listreprintsname}{List of publications of the author
reprinted in this volume}
        
\newlistof{reprints}{lop}{\listreprintsname}

\newcommand{\reprint}[1]{
 \cleardoublepage
 \refstepcounter{reprints}
 \addcontentsline{lop}{reprints}{\protect \bibentry{#1}.}
 \protect\label{rep:#1}
 \includepdf[pages=-]{C:/Gregor/Litera/#1.pdf}} 

Creating .pdf-files from TeX

Today (2003) you don't need to own the expensive Acrobat suite (not just the reader!) anymore to create efficient and beauiful pdf documents anymore. Starting from a TeX document pdfTeX and pdfLaTeX will create very nice small files. If, for some reason, you don't want to use these you can still use LaTeX, DVIPS, and then the GhostScript pdfwrite device driver. (GSView will help you here). I found that Acrobat Distiller (5.0) still has a slight advantage over GhostScript at times, but it doesn't seem worth the extra money.

There are a few considerations reagrding fonts: You should instruct DVIPS to use postscript fonts (in the config.ps configuration file) and to embed them fully into (run with -j0 option) into the document, otherwise Distiller can run into errors and some characters might be missing. In case you find that some characters are still missing also instruct Distiller to embed all fonts totally.

For efficient cross-referencing in the document I recommend to use the hyperref-package. A sample inclusion of that package:

\usepackage[dvips, a4paper, hyperfigures=false, colorlinks=true, 
pagecolor=blue, linkcolor=blue, pagebackref=true, hyperfigures=true,
bookmarks=true, bookmarksopen=true, pdfauthor={Gregor Weihs},
pdftitle={Ein Experiment zum Test der Bellschen Ungleichung unter
Einsteinscher Lokalitaet}, pdfsubject={Experimental test of Bell's inequality under strict Einstein locality conditions}]{hyperref}

The package will automatically create an active toc and hyperrefs for bibliography entries, figures, etc. and also define some commands as \href with which you can easily include web-references:

\href{http://www.oeaw.ac.at}{\textbf{\"{O}sterreichischen Akademie der Wissenschaften}

Miscellaneous LaTeX tips

In the standard LaTeX classes there is no command to produce an unnumbered chapter, which yet appears in the TOC and page headers. To achieve this use

\chapter*{<heading>}
\addcontentsline{toc}{chapter}{<heading>}
\markboth{<heading>}{<heading>}

or in the KOMA-script classes

\addchap{<heading>} 

will do the same.

I ran across a difficult to resolve error recently. I had said

\footnote{.. \marginpar{...} ...}

and a couple of pages later LaTeX said

! LaTeX Error: Float(s) lost.

I know it doesn't make sense to call a margin paragraph from a footnote but the error message was no help at all. It turns out that margin paragraphs are using the float mechanism and the error won't appear before the next \clearpage (e.g. in \chapter) command.

A few cool Search-Replace regular expressions
for Winedt's regexp engine

This will replace leading " quotes with proper TeX `` notation:

Search: \(0{<|^[\\]}\)\"~{ |[,.;:!\?)]}
Replace: \0``

 

Other useful software

TexPoint

TexPoint is the final solution to formula typesetting for presentations. It would be really useful in MS Word and other programs (CorelDraw for my part), but there seem to be problems. Now it can even use TrueType fonts and emf embedding which means that your display equations are truly scalable.

jpeg2ps

Jpeg2ps is a quick utility that will wrap a jpeg bitmap with some little Postscript code to produce a jpeg-encoded eps image. There is simply no way to produce a more efficiently coded Postscript figure. I usually use it with the -h switch to produce ASCIIHex encoded images, because our HP LaserJet 4100 used to fail one some ASCII85 encoded images. If only there existed a similar tool for some lossless compressed bitmap or compressed vector format (I've been struggling with the people that run arXiv.org).

Programming

One of my latest little projects was to make the daily email listings I receive from arXiv.org (scientific preprints) easier to read by converting them from their plain text format to pretty HTML. While it took me only an hour to write a Perl script that does the trick it cost me almost days to actually call this script from a VBA program that is run from an MS Outlook rule on the incoming arXiv messages.
I converted the Perl script to a so called Windows Script Component. This results in an object that you can instantiate from VBA. I did encounter come strange behavior that I couldn't resolve. Everything works fine as long as I open at least one dialog box in the Script component. If I don't do that, as I had initially planned, Outlook shuts down without a beep and the script never finishes.
If you're interested, have a look at arxiv2html.wsc, and processarxiv.bas
Recently I found that Visual Basic comes with its own regular expressions, so I could have done everything in VBA. With a very recent (I installed it in April 2004) service pack to Office 2002 Outlook becomes even more carfeul when running scripts and will prompt you to allow access. I have adapted my script to use the free Redemption classes that get around this security feature.

MySQL and Access

MySQL has the handy and efficient"enum" field type, when a separate table and a relation would be too much overhead. MS Access, which you may want to use as an interface to MySQL tables doesn't provide an equivalent field type. You can, however, supplement any field with a lookup table in the form of a value list. The following VB code takes the values from an SQL query to MySQL and stores them in the field of the linked table as a lookup list. (It doesn't actually configure the control type, but that would be easy from here).

Function UpdateFieldValues()

Dim db  As DAO.Database
Dim tbl As DAO.TableDef
Dim rst As DAO.Recordset

Set db = CurrentDb
Set tbl = db.TableDefs("Participants")
Set rst = db.OpenRecordset("ExtractParticipantFields", dbOpenDynaset)
        
' ADO version: rst.Open "ExtractParticipantFields", 
' CurrentProject.Connection, adOpenStatic Do While Not rst.EOF tbl.Fields(rst.Fields("Field")).Properties("RowSource") =
rst.Fields("Values") rst.MoveNext Loop
End Function
        

The stored query "ExtractParticipantFields" extracts the list of enum values for each enum field from the following SQL statement: "SHOW COLUMNS FROM Participants" The VB code then enters this list for all of the enum fields.

Computer problems and annoyances

This is the point where I pose questions to the web on issues that I was never able or never had the time to resolve.

Windows (mostly XP)

  • Rampant helpsvc: Often times I found my computer (Windows XP Prof.) grinding away at its hard disk and almost unresponsive. The reason is invariably a helpsvc.exe process that consumes all the memory, CPU share and disk access it can get. I didn't find any problems in killing it but it is an annoyance. Update: I found instructions for a possible fix at http://www.answersthatwork.com/Tasklist_pages/tasklist_h.htm Also this problem seems to have disappeared with updates to XP.
  • Run Explorer as another user and efficiently manipulate file permissions: Frequently I am working as a regular user on a Windows machine and then I'd like to set some file system, or sharing permissions using an Administrator account. Now, the runas utility should come in handy here but then you can't start another explorer. (Although I'd think that if I set "start each explorer window in a separate process" this could work. - No it doesn't!) Update: I haven't followed this question for a while and it has been solved by others: You need to set the option for both users the source and target of the runas. Thanks to Joep Lohmann for this tip.
  • Local UNC paths: It is an annoyance that no version of Windows will resolve local UNC paths (like //mymachine.stanford.edu/documents on mymachine) without an active network interface. In MS language: "This behavior is by design". UNC paths are always resolved through the network, even if they point to local resources. Apparently this is to maintain the additional security layer.
    One possible application would be to have your home directory point to a share on your mobile computer via a UNC path. This way, if you log on to another machine it would point to the mobile computer (which should be connected to the netowrk, of course). If you are away with your mobile computer the same logon would give you the same home directory, this time on the local machine.
    A way around this is to always leave you network adapter enabled, even if it's not connected, or to install the MS loopback network adapter (a virtual adapter).
    I understand that the problem I am trying to solve is better solved by having the home directory on a server and making the share available offline but I haven't tried that yet.

Samba

  • Stalled Samba transfers: We've been having problems with our RedHat 7.3 installations through all versions of Samba. Whenever we would try to transfer large files to or from either an smbmounted directory or using smbclient the transfers would stall at some point. I couldn't find any help in newsgroups or the Samba documentation.
  • smbclient: This is actually a solved problem: We have an independent Linux workstation and a couple of Windows PCs that are members of a Windows 2000 native domain. Often I'd want to get data from a Windows machine using smbclient/smbmount on the Linux one. Now, our site policy asks for NTLMv2 as the mininmum authentication mechanism on domain accounts. Samba 2.x.y apparently can't provide this - or at least I couldn't convince it. Now in Samba 3.0.4 I found an option to samba.conf that "allows" the client to use this mechanism. It reads "client ntlmv2 auth = yes". If you are not root on your machine you can provide your own samba.conf in a command line like
    smbclient \\<host>\<share> -s samba.conf -W <DOMAIN> -U <username>

MS Word

  • No tables at the end: On of the biggest bugs in MS Word (any version I've ever used) is that you can't put a table at the end of a document without having at least one (possibly empty) paragraph after it. Very often this extra paragraph will force an extra page at the end. This is just stupid.
  • Too much vertical justification: Have you ever tried to typeset an MS Word Document vertically justified? This means that you want the top of a page and the bottom of the text on a page to be flush with the set margins. Why would you want that? Well, especially in a double sided document you want the left and right pages of an open book to be flush, top and bottom. This feature is achieved by stretching the vertical space between paragraphs. Now, MS Word will do this but it will also on the last page try to make the text flush, even if there is only one or two short paragraphs. If there is two, one will be at the top, the other one at the bottom, if there is one it will sit around the middle of the page, making it look really odd. I've tried section breaks, etc. there is just no solution. This would be like stretching a the last line of a justified paragraph to be flush on both sides, even if there are only two words in this line. It took 6 rounds before the MS support person actually acknowedged that this is a problem, but I also learned that they won't correct it anytime soon.

CorelDraw

  • I had a tough time trying to get Matlab plots into CorelDraw. In version 11.0 (SP1) CorelDraw has problems with various copy/paste and equivalent .wmf/.emf imports. Elements will be missing and/or misplaced. This happens from Matlab and MS applications but things are OK when copy/pasting from Origin.
  • The alternative of using .eps files seems to have the problem that the way Matlab encodes its .eps CorelDraw is not able to import text as text. It will always be curves. If you don't want to edit the text that's fine.
  • The third option, using .pdf comes with excessive lineweights (5pt instead of 0.5pt). Text is fine here. There are no other vector formats that Matlab supports, consequently there is no correct way to get Matlab plots into CorelDraw if you don't want them rasterized.

Powerpoint

  • Custom shows are an excellent idea but badly implemented. There should be a slide chooser and sorter for them. MS could just make it as a named selector in the slide sorter view. In the presenter's view - I really like this feature - for dual screen configurations custom shows are (as are hidden slides) are not properly represented.