From mboxrd@z Thu Jan 1 00:00:00 1970 From: Carsten Dominik Subject: Re: Bernt's document and LaTeX [was: Re: http://doc.norang.ca/org-mode.html ] Date: Tue, 9 Jun 2009 06:28:42 +0200 Message-ID: References: <26E81FB3-E33C-472C-B5B3-9548B0554B68@gmail.com> <9308.1244508074@gamaville.dokosmarshall.org> Mime-Version: 1.0 (Apple Message framework v935.3) Content-Type: text/plain; charset=WINDOWS-1252; format=flowed; delsp=yes Content-Transfer-Encoding: quoted-printable Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MDsxE-00073L-HY for emacs-orgmode@gnu.org; Tue, 09 Jun 2009 00:28:56 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MDsx9-0006yL-1i for emacs-orgmode@gnu.org; Tue, 09 Jun 2009 00:28:55 -0400 Received: from [199.232.76.173] (port=36033 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MDsx8-0006y7-Rn for emacs-orgmode@gnu.org; Tue, 09 Jun 2009 00:28:50 -0400 Received: from mail-ew0-f223.google.com ([209.85.219.223]:50115) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MDsx8-00008B-6n for emacs-orgmode@gnu.org; Tue, 09 Jun 2009 00:28:50 -0400 Received: by ewy23 with SMTP id 23so3643ewy.42 for ; Mon, 08 Jun 2009 21:28:48 -0700 (PDT) In-Reply-To: <9308.1244508074@gamaville.dokosmarshall.org> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: nicholas.dokos@hp.com Cc: emacs-orgmode mailing list Hi Nick, that was educational! :-) I have pushed a tentative fix, please verify. - Carsten On Jun 9, 2009, at 2:41 AM, Nick Dokos wrote: > Carsten Dominik wrote: > >> I would like to encourage you all to take another looks at Bernt's >> nearly completed document over at >> >> http://doc.norang.ca/org-mode.html >> >> If you are serious about using Org-mode to get organized, this >> is simply an awesome resource of ideas, customization snippets, >> tips and tricks. I am learning looking at that, too. >> >> Thanks for doing this, Bernt. >> > > Seconded, thirded and fourthed: thanks Bernt! > > And while we are on the subject of Bernt's document: I haven't =20 > looked at > the most recent incarnation on Bernt's website, but I got his org file > from worg the other day and I tried to export it to LaTeX/PDF and =20 > print > a copy to read (I prefer paper for documents that I'd like to read > carefully - in this case, I can also put the printed document under my > pillow: I hear it's the only way for hopeless cases like me to get > organized !-) > > But I ran into a problem with the LaTeX exporter. > > Bernt uses code emphasis in a bunch of places, e.g. with TODO =20 > keywords, > like the following: > > ,---- > | *** Normal Task States > | Normal tasks go through the sequence =3DTODO=3D -> =3DSTARTED=3D -> = =3DDONE=3D. > | The second sequence is really just a convenient collection of odd-=20= > ball > | states for tasks (=3DWAITING=3D, =3DSOMEDAY=3D, =3DCANCELLED=3D). > `---- > > but also in headings, like this: > > ,---- > | *** Using =3DSTARTED=3D for clocked tasks > | Tasks automatically change to =3DSTARTED=3D whenever they are =20= > clocked in. > `---- > > The LaTeX exporter turns these into the following: > > ,---- > | \subsubsection{Normal Task States} > | \label{sec-3.1.1} > | > | Normal tasks go through the sequence \verb~TODO~ -> \verb~STARTED~ =20= > -> \verb~DONE~. > | The second sequence is really just a convenient collection of odd-=20= > ball > | states for tasks (\verb~WAITING~, \verb~SOMEDAY~, \verb~CANCELLED~). > `---- > > and > > ,---- > | \subsubsection{Using \verb~STARTED~ for clocked tasks} > | \label{sec-3.3.1} > | > | Tasks automatically change to \verb~STARTED~ whenever they are =20= > clocked in. > `---- > > But \verb is a "fragile" command and cannot be used in a moving =20 > argument > (e.g. a subsubsection heading - it's a "moving" argument because it's > going to be "moved around" on its way to the table of contents and its > expansion has to be timed correctly), so LaTeX complains about the =20 > \verb > in the \subsubsection title above. The standard way to deal with this > problem is to \protect the fragile command: use \protect\verb =20 > instead of > \verb in the moving argument. I did something simpler: I tweaked the > exporter to \protect every \verb - afaik, this might be inefficient, =20= > but > it should not cause a problem. I did that with the following patch: > > --- a/lisp/org-latex.el > +++ b/lisp/org-latex.el > @@ -1377,7 +1385,7 @@ The conversion is made depending of STRING-=20 > BEFORE and STRING-AFTER." > (if (not (string-match (regexp-quote (substring ll i (1+ = i))) > string)) > (progn > - (setq format (concat "\\verb" (substring ll i (1+ = i)) > + (setq format (concat "\\protect\\verb" (substring = ll i (1+ =20 > i)) > "%s" (substring ll i (1+ = i)))) > (throw 'exit nil)))))))) > (setq string (org-export-latex-protect-string > > The resulting LaTeX document has every \verb properly (NOT!) > \protect'ed. But LaTeX sure does not like the result: > > ,---- > | This is pdfTeXk, Version 3.141592-1.40.3 (Web2C 7.5.6) =20 > (format=3Dpdflatex 2009.2.9) 8 JUN 2009 18:17 > | entering extended mode > | %&-line parsing enabled. > | **org-mode.tex > | (./org-mode.tex > | LaTeX2e <2005/12/01> > | Babel and hyphenation patterns for english, usenglishmax, =20= > dumylang, noh > | yphenation, pinyin, loaded. > | (/usr/share/texmf-texlive/tex/latex/base/article.cls > | Document Class: article 2005/09/16 v1.4f Standard LaTeX document =20 > class > | > | ....lots of stuff elided .... > | > | [15] [16] [17] > | Runaway argument? > | the \protect \relax \hbox {}#I\catcode `\ \active \-command =20 > \csname\endcsn > | ame > | ! Paragraph ended before \HyPsd@@ProtectSpaces was complete. > | > | \par > | l.918 ...ct\verb~STARTED~ task list under control} > | > | ? > `---- > > The funny thing is that there are four instances of this construct in > Bernt's document: > > ,---- > | ... > | \subsubsection{Using \protect\verb~STARTED~ for clocked tasks} > | ... > | \subsubsection{Why keep it all on the \protect\verb~STARTED~ list?} > | ... > | \subsection{Keeping the \protect\verb~STARTED~ task list under =20 > control} > | ... > | \subsubsection{\textbf{UNFINISHED} Using \protect\verb~f5~} > | ... > `---- > > and it's only the third one that causes a problem: if I get rid of the > markup on that one, pdfLaTeX finishes normally. Aha! I noted that =20 > the problem > is a \subsection argument, whereas the others are \subsubsection > arguments - the former appears in the TOC, whereas the latter do not =20= > by > default - but if I change the \tocdepth from the default 2 to 3, =20 > then subsubsections > get added to the table of contents and then LaTeX barfs on those =20 > too: \protect is > a bust. > > After doing a little research, I found out that \verb is not just =20 > "fragile": > it's *special* (see e.g. = http://www.tex.ac.uk/cgi-bin/texfaq2html?label=3Dverbwithin > where I find: > > This is why the LaTeX book insists that verbatim commands must =20= > not > appear in the argument of any other command; they aren=92t just > fragile, they=92re quite unusable in any command parameter, > regardless of \protection. (The \verb command tries hard to =20 > detect > if you=92re misusing it; unfortunately, it can=92t always do so, = and > the error message is therefore not a reliable indication of > problems.) > > The suggested workaround is to actually use \texttt{foo}, instead of > \verb~foo~ where the two would give identical results. This has > problems of its own: the main one is things like underscores which =20 > would > need to be escaped. But I wonder if the LaTeX exporter should go this > way, rather than fighting with \verb all the way (and losing). Or if =20= > we > can distinguish between body instances and section heading =20 > instances, do > the \texttt{foo} transformation only on the latter. > > Comments? > > Thanks, > Nick >