<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <id>tag:blog.danieljanus.pl,2019:category:latex</id>
  <title>Daniel Janus – LaTeX</title>
  <link href="http://blog.danieljanus.pl/category/latex/"/>
  <updated>2008-04-10T00:00:00Z</updated>
  <author>
    <name>Daniel Janus</name>
    <uri>http://danieljanus.pl</uri>
    <email>dj@danieljanus.pl</email>
  </author>
  <entry>
    <id>tag:blog.danieljanus.pl,2008-04-10:post:recipe-for-successful-presentation</id>
    <title>Recipe for a successful presentation</title>
    <link href="http://blog.danieljanus.pl/recipe-for-successful-presentation/"/>
    <updated>2008-04-10T00:00:00Z</updated>
    <content type="html">&lt;div&gt;&lt;p&gt;&lt;a href="http://www.latex-project.org/"&gt;LaTeX&lt;/a&gt; + &lt;a href="http://latex-beamer.sourceforge.net/"&gt;Beamer&lt;/a&gt; (for typesetting the presentation in a visually pleasant, clean, simple and consistent way) + &lt;a href="http://impressive.sourceforge.net/"&gt;KeyJNote&lt;/a&gt; (for presenting it stylishly to the audience) = a recipe for success. In particular, KeyJNote, which I found only yesterday, seems to be a fine and tremendously useful piece of software, despite being very young. The only annoyance I have found in it is that it doesn’t respond to Alt-Tab when in fullscreen mode. On the typographical side, I used the &lt;a href="http://www.cert.fr/dcsd/THESES/sbouveret/francais/LaTeX.html"&gt;progressbar&lt;/a&gt; Beamer theme and the &lt;a href="http://www.nowacki.strefa.pl/torunska-e.html"&gt;Torunian Antiqua&lt;/a&gt; font, both to great effect.&lt;/p&gt;&lt;p&gt;While I’m at this topic, &lt;a href="http://jan.rychter.com/"&gt;Jan Rychter&lt;/a&gt; has recently posted &lt;a href="http://jan.rychter.com/blog/files/sztuka-prezentacji-03-2008.html"&gt;a great guide to giving presentations&lt;/a&gt;, especially short ones. I heartily recommend it to those of you who speak Polish (is there actually any non-Polish-speaking person reading this?)&lt;/p&gt;&lt;p&gt;&lt;em&gt;Update 2010-Jan-17&lt;/em&gt;: KeyJNote is now called &lt;a href="http://impressive.sourceforge.net/"&gt;Impressive&lt;/a&gt;.&lt;/p&gt;&lt;/div&gt;</content>
  </entry>
  <entry>
    <id>tag:blog.danieljanus.pl,2008-04-06:post:tex-hackery</id>
    <title>The TeX Hackery</title>
    <link href="http://blog.danieljanus.pl/tex-hackery/"/>
    <updated>2008-04-06T00:00:00Z</updated>
    <content type="html">&lt;div&gt;&lt;p&gt;After a longish while of inactivity, I finally got around to finishing the draft spec of a next-generation protocol for &lt;a href="http://poliqarp.sf.net/"&gt;Poliqarp&lt;/a&gt;, the be-all-end-all corpus concordance tool that I maintain. The spec is being written in LaTeX, and it has a number of subsections that describe particular methods of the protocol. Each one of those is further divided into sub-subsections that describe the method’s signature, purpose, syntax of request, syntax of response, and an optional example. I thought to write a couple of macros to help me separate the document’s logic from details of formatting, so that I could say:&lt;/p&gt;&lt;pre&gt;&lt;code class="hljs latex"&gt;&lt;span class="hljs-keyword"&gt;\synopsis&lt;/span&gt;/() -&amp;gt; {version : int; extensions : string*}/
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;and have it expanded into:&lt;/p&gt;&lt;pre&gt;&lt;code class="hljs latex"&gt;&lt;span class="hljs-keyword"&gt;\paragraph&lt;/span&gt;{Synopsis}
&lt;span class="hljs-keyword"&gt;\verb&lt;/span&gt;/&lt;span class="hljs-string"&gt;{version : int; extensions : string*}&lt;/span&gt;/
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Being a casual LaTeX user who hardly ever writes his own macros, I first thought to use LaTeX’s command-defining commands, &lt;code&gt;\newcommand&lt;/code&gt; and &lt;code&gt;\renewcommand&lt;/code&gt;. However, I quickly ran into the limitation that the argument of commands defined in such a way can only be delimited by curly braces, which I could not use because they might appear in the argument itself.&lt;/p&gt;&lt;p&gt;I googled around and found that this limitation can be overcome by using &lt;code&gt;\def&lt;/code&gt; instead, which is not a LaTeX macro but rather an incantation of plain TeX, and allows to use arbitrary syntax for delimiting arguments. Having found that, my first shot was:&lt;/p&gt;&lt;pre&gt;&lt;code class="hljs latex"&gt;&lt;span class="hljs-keyword"&gt;\def&lt;/span&gt;&lt;span class="hljs-keyword"&gt;\synopsis&lt;/span&gt;/&lt;span class="hljs-params"&gt;#1&lt;/span&gt;/{&lt;span class="hljs-keyword"&gt;\paragraph&lt;/span&gt;{Synopsis}&lt;span class="hljs-keyword"&gt;\verb&lt;/span&gt;/&lt;span class="hljs-string"&gt;#1&lt;/span&gt;/}
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;which, obviously enough, turned out not to work, producing errors about &lt;code&gt;\verb&lt;/code&gt; ended by an end-of-line.&lt;/p&gt;&lt;p&gt;“What the heck?” I thought, and resorted to Google again, this time searching for tex macros expanding to verb. This yielded an entry from some TeX FAQ, which basically states that the &lt;code&gt;\verb&lt;/code&gt; is a “fragile” command, and as such it cannot appear in bodies of macros. Ook. So it can’t be done?&lt;/p&gt;&lt;p&gt;“But,” I thought, “TeX is such a flexible and powerful tool, there must be some way around this!” And, as it would turn out, there is. Yet more googling led me to &lt;a href="http://groups.google.pl/group/comp.text.tex/browse_thread/thread/5bca05fb8865a9c2"&gt;this thread&lt;/a&gt; on comp.text.tex, where someone gives the following answer for a similar question:&lt;/p&gt;&lt;pre&gt;&lt;code class="hljs latex"&gt;&lt;span class="hljs-keyword"&gt;\def&lt;/span&gt;&lt;span class="hljs-keyword"&gt;\term&lt;/span&gt;&lt;span class="hljs-params"&gt;#&lt;/span&gt;{ &lt;span class="hljs-comment"&gt;%&lt;/span&gt;
   &lt;span class="hljs-keyword"&gt;\afterassignment&lt;/span&gt;&lt;span class="hljs-keyword"&gt;\Term&lt;/span&gt; &lt;span class="hljs-keyword"&gt;\let&lt;/span&gt;&lt;span class="hljs-keyword"&gt;\TErm&lt;/span&gt;= }&lt;span class="hljs-comment"&gt;%&lt;/span&gt;

&lt;span class="hljs-keyword"&gt;\edef&lt;/span&gt;&lt;span class="hljs-keyword"&gt;\Term&lt;/span&gt;{&lt;span class="hljs-keyword"&gt;\noexpand&lt;/span&gt;&lt;span class="hljs-keyword"&gt;\verb&lt;/span&gt; \&lt;span class="hljs-string"&gt;string}}
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Now this is overkill. Why in the world am I forced to stuff such incomprehensible hackery into my document just to perform a seemingly simple task?! Easy things should be easy — that’s one of the principles of good design.&lt;/p&gt;&lt;p&gt;Reluctantly, I copied it over, and attempted to adjust it to my needs. After a number of initial failed attempts, I thought that I might actually attempt to understand what all these &lt;code&gt;\afterassignment&lt;/code&gt;’s, &lt;code&gt;\noexpand&lt;/code&gt;’s and &lt;code&gt;\edef&lt;/code&gt;’s are for, so I downloaded the &lt;a href="http://www-cs-faculty.stanford.edu/~knuth/abcde.html"&gt;TeXbook&lt;/a&gt; and dived straight in.&lt;/p&gt;&lt;p&gt;I spent another fifteen minutes or so reading bits of it and trying to understand tokens, macros, when they are expanded and when merely carried over, etc. But a sparkle of thought made me replace the whole complicated thingy with a simple snippet that actually worked.&lt;/p&gt;&lt;pre&gt;&lt;code class="hljs latex"&gt;&lt;span class="hljs-keyword"&gt;\def&lt;/span&gt;&lt;span class="hljs-keyword"&gt;\synopsis&lt;/span&gt;{&lt;span class="hljs-keyword"&gt;\paragraph&lt;/span&gt;{Synopsis}&lt;span class="hljs-keyword"&gt;\verb&lt;/span&gt;}&lt;span class="hljs-string"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;That’s right. This superficially resembles a C preprocessor macro, and works because I was lucky enough to have &lt;code&gt;\verb&lt;/code&gt; appear last in the definition, thus allowing the “arguments” of &lt;code&gt;\synopsis&lt;/code&gt; to be specified just like arguments to &lt;code&gt;\verb&lt;/code&gt; and fit at exactly right place. I’m almost certain that it does not always work this way, but for now it’ll suffice.&lt;/p&gt;&lt;p&gt;Oh well. TeX is undoubtedly a fine piece of software that provides splendid results if used right. But I can’t get over the impressions that there are a great deal more idiosyncracies like this in it than in, say, Common Lisp, even though the latter’s heritage tracks back to as early as 1958 and is a whopping twenty years longer than TeX’s. (On the side note, as it turns out, someone has already written &lt;a href="http://www3.interscience.wiley.com/cgi-bin/abstract/98518913/ABSTRACT"&gt;a Lisp-based preprocessor for TeX macros&lt;/a&gt;. Gotta check it out someday.)&lt;/p&gt;&lt;p&gt;As for the TeXbook itself: it is a fine piece of documentation that I will definitely have to add to my must-read list, though it admittedly has a math-textbookish feel to it. First, however, I want to finish “Shaman’s Crossing” by Robin Hobb (which I will probably brag about in a separate post once I’m finished with it) and tackle Christian Queinnec’s “Lisp in Small Pieces”.&lt;/p&gt;&lt;/div&gt;</content>
  </entry>
</feed>
