[atom feed]

Jochen's Blog

38321 jvjsdoc, a documentation generator for JavaScript
2011-12-11

This weekend, I finished a new program: JvJsDoc, a program to extract documentation from JavaScript source code and to present the collected information in a set of HTML pages. It is meant to be used together with the Google Closure Library and the Google Closure Compiler. As an example: JvJsDoc can convert the JavaScript source file goog/disposable/disposable.js into the HTML documentation in goog/Disposable.html.

More information can be found on the JvJsDoc homepage, and you can download the program here:

jvjsdoc version 0.5, 2011-12-11

First public release.

61227 new paper
2011-10-20

After taking much longer than I intended to, today I finally submitted a new paper (about a year later than planned). You can have a look at the preprint here:

76874 new jvlisting release
2011-10-17

jvlisting is a LaTeX package which provides an alternative to LaTeX's built-in verbatim environment. The new release, version 0.5, fixes some bugs and cleans up the TeX source code a bit.

I hope you find this package useful. Bug reports and comments are very welcome!

73572 Some Fundamental Properties of Multivariate von Mises Distributions
2011-09-27

Last week, Kanti and I submitted a new paper:

I am particularly curious about how the referees will react to my nice figures on pages 6 and 7.

14184 statistical computing
2011-09-23

I have typed my lectures notes for the statistical computing module I am teaching this term. The notes are available online:

Comments are very welcome!

57298 playing with Google+
2011-09-06

I just started playing with Google+, not sure yet whether this will be useful or interesting to me. If you also want to play, and don't have an account yet, you can probably sign up at this link.

38071 watching DVDs on an Apple iPad
2011-07-28

Just for reference, here is a recipe about how to watch your DVDs on an Apple iPad. I have read that some of the required steps may be illegal to perform when you are in the USA (or an American citizen?); don't follow these instructions if you are not allowed to!

The instructions provided here use MPlayer/MEncoder on Ubuntu Linux to convert the DVD content into a file of the required format, but many other options are available.

19498 new LaTeX package "jvlisting"
2011-07-27

A while ago I finished my first home-made LaTeX package. The new package is called "jvlisting" and provides a replacement for LaTeX's verbatim environment.

This package provides the LaTeX environment listing, an alternative to the built-in verbatim environment. The listing environment is specially taylored for including listings of computer program source code into documents. The main advantages over the original verbatim environment are that

You can download the package and its documentation from my webserver or from the jvlisting page at the Common TeX Archive Network (CTAN). I'd be happy if you could give my package a try. Comments about jvlisting are very welcome!

59190 LaTeX: calling a macro for every line of input
2011-06-21

Recently I spent some time to understand how one can execute a macro repeatedly, once for every line of text in a LaTeX environment. Since the solution is a bit tricky and I found it diffcult to find answers on the web, here is a summary of what I learned.

Step 1. In order to prevent input lines from being concatenated by TeX before we get access to them, we can use the \obeylines macro. This allows to define a macro which matches everything until the end of line:

\def\doline#1{line found: `#1'\par}
{\obeylines
\gdef\getline#1
  {\doline{#1}}}

{\obeylines
\getline This is the \textbf{first} line.
This is the second line.}

Note that \obeylines must be in effect both while we define the \getline macro and while scanning the text. The outer pairs of enclosing brackets are there to contain the effect of \obeylines. To make \getline visible outside these brackets we use \gdef to define the macro in the global namespace. The output of the above TeX code is

line found: ‘This is the first line.’
This is the second line.

Step 2. We would like to have the \getline macro called for every line instead of just for the first one. This can be achieved by putting a \getline (without arguments) at the end of the \getline replacement text. The only complication is that we somehow need to stop this procedure once the end of the region of interest has been reached:

\def\marker{END}
{\obeylines
\gdef\getlines#1
  {\def\text{#1}%
  \ifx\text\marker \let\next\empty
    \else \doline{#1}\let\next\getlines \fi
  \next}}

{\obeylines
\getlines This is the \textbf{first} line.
This is the second line.
END
}

The \ifx command is used to test whether the matched line is the same as \marker. Until we find the maker, we put a new call to \getlines at the end of the \getlines replacement text, thereby looping over all lines until the marker is found. For this to work, the END needs to occur on a line on its own; therefore we have to move the closing brackets down one line. The TeX code above leads to the following output.

line found: ‘This is the first line.’
line found: ‘This is the second line.’

Step 3. We are now ready to pack the commands from above into the definition of a LaTeX environment:

\def\marker{\end{dolines}}
{\obeylines
\gdef\getlines#1
  {\def\text{#1}%
  \ifx\text\marker \let\next\text
    \else \doline{#1}\let\next\getlines \fi
  \next}}
\newenvironment{dolines}{\begingroup\obeylines\getlines}%
  {\endgroup}

\begin{dolines}
This is the \textbf{first} line.
This is the second line.
\end{dolines}

Here we had to change the definition of \getlines in order to include the \end{dolines} in the replacement text when the \ifx is true; otherwise it would have been swallowed by \dolines. The resulting output is, a bit surprisingly, as follows:

line found: ‘’
line found: ‘This is the first line.’
line found: ‘This is the second line.’

The extra empty line at the beginning is caused by the \getlines macro matching the (empty) text between \begin{dolines} and the end of line. The \end{listing} must be on a line on its own for this environment to work.

Step 4. If we want to prevent processing of the TeX commands inside the dolines environment, we can do so by changing the category codes of special characters like \ to 12 (other). A complication with this plan is, that \ifx also compares category codes. Therefore, when we try to detect the end of our environment while special characters are switched off, we need to define \marker as the string \end{dolines}, but with the category codes of all special charcters (the backslash and the curly brackets) set to 12. This can be done by using the following, contorted sequence of commands:

\begingroup
\catcode`|=0 \catcode`[=1 \catcode`]=2
\catcode`\{=12 \catcode`\}=12 \catcode`\\=12
|gdef|marker[\end{dolines}]
|endgroup

Two more changes are required to make this work: first, we need to disable all special characters at the beginning of the environment:

\let\do=\@makeother\dospecials

If you want to use this command outside a style file, you will need to turn @ into a letter by bracketing your definitions with

\makeatletter
...
\makeatother

Secondly, inside \getlines, the expansion of \text still has the category codes as found in the input. Therefore, if the input was read with special characters switched of, we cannot write \let\next\text to get the closing \end{dolines} (since the category codes of the backslash and the curly brackets would be wrong). Instead, we need to use a definition like \def\next{\end{dolines}}.

Example. Using the techniques explained above, we can define a replacement for the LaTeX comment environment (contained in the verbatim package) as follows:

\documentclass{article}

\makeatletter

\begingroup
\catcode`|=0 \catcode`[=1 \catcode`]=2
\catcode`\{=12 \catcode`\}=12 \catcode`\\=12
|gdef|marker[\end{comment}]
|endgroup

{\obeylines
\gdef\getlines#1
  {\def\text{#1}%
  \ifx\text\marker \def\next{\end{comment}}
    \else \let\next\getlines \fi
  \next}}
\newenvironment{comment}{\begingroup
    \let\do=\@makeother\dospecials \obeylines\getlines}%
  {\endgroup}

\makeatother

\begin{document}

\begin{comment}
  Everything here will be ignored.
  \Invalid LaTeX code and incomplete constructs like
  \begin{itemize}
  without the closing end are no problem.
\end{comment}

\end{document}

89818 old papers
2011-03-23

Funny coincidence: Yesterday I learned that the following paper which we first submitted in 2010 has been accepted:

And today I received an email notice that a paper we submitted in 2009(!) is finally going into print now:

Older entries can be found on the next page

Creative Commons License

Copyright © 2011, Jochen Voss. All content on this website (including text, pictures, and any other original works), unless otherwise noted, is licensed under a Creative Commons Attribution-Share Alike 3.0 License.