From mboxrd@z Thu Jan 1 00:00:00 1970 From: Lawrence Bottorff Subject: Tangled Latex code gives error Date: Sun, 26 Apr 2015 19:20:31 -0400 Message-ID: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=047d7b6d98de2a45eb0514a8e0f9 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:39279) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YmVqm-0003kq-B5 for emacs-orgmode@gnu.org; Sun, 26 Apr 2015 19:20:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YmVqj-0002iG-Ew for emacs-orgmode@gnu.org; Sun, 26 Apr 2015 19:20:36 -0400 Received: from mail-pa0-x232.google.com ([2607:f8b0:400e:c03::232]:35982) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YmVqj-0002eA-2j for emacs-orgmode@gnu.org; Sun, 26 Apr 2015 19:20:33 -0400 Received: by pabsx10 with SMTP id sx10so109488875pab.3 for ; Sun, 26 Apr 2015 16:20:31 -0700 (PDT) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org --047d7b6d98de2a45eb0514a8e0f9 Content-Type: text/plain; charset=UTF-8 I'm following the Latex howto of org-mode babel. Here's the snippet from the howto I've got in a separate .org file (see bottom of howto page): #+LATEX_HEADER: \usepackage{tikz} First execute the second code block, to define the convenience macro and to set the required new variables in ob-latex.el. Then export to HTML and to pdf to see the tree exported as an SVG image and as embedded tikz respectively. * Tikz test Here's a tree, exported to both html and pdf. #+header: :file (by-backend (html "tree.svg") (t 'nil)) #+header: :imagemagick #+header: :results (by-backend (pdf "latex") (t "raw")) #+header: :tangle yes #+begin_src latex \usetikzlibrary{trees} \begin{tikzpicture} \node [circle, draw, fill=red!20] at (0,0) {1} child { node [circle, draw, fill=blue!30] {2} child { node [circle, draw, fill=green!30] {3} } child { node [circle, draw, fill=yellow!30] {4} }}; \end{tikzpicture} #+end_src * COMMENT setup #+header: :tangle yes #+begin_src emacs-lisp :results silent (setq org-babel-latex-htlatex "htlatex") (defmacro by-backend (&rest body) `(case (if (boundp 'backend) (org-export-backend-name backend) nil) ,@body)) #+end_src This doesn't really produce a .svg of the tree as advertised, but exporting to Latex does produce it just fine. My real confusion starts when I try to tangle the babel code blocks. The C-c C-v t command produces two separate files just fine, a .tex and .el, but then if I try to Run Latex on the .tex file just by itself it gives an error. Here's what the org-mode tangle produces: \usetikzlibrary{trees} \begin{tikzpicture} \node [circle, draw, fill=red!20] at (0,0) {1} child { node [circle, draw, fill=blue!30] {2} child { node [circle, draw, fill=green!30] {3} } child { node [circle, draw, fill=yellow!30] {4} }}; \end{tikzpicture} And here's the error log after I try to run it by itself in Emacs: . . .entering extended mode restricted \write18 enabled. file:line:error style messages enabled. %&-line parsing enabled. **\input prac2.tex (./prac2.tex ./prac2.tex:2: Undefined control sequence. l.2 \usetikzlibrary {trees} The control sequence at the end of the top line of your error message was never \def'ed. If you have misspelled it (e.g., `\hobx'), type `I' and the correct spelling (e.g., `I\hbox'). Otherwise just continue, and I'll forget about whatever was undefined. Another version (from C-c `) produces this error message: ERROR: Undefined control sequence. --- TeX said --- l.2 \usetikzlibrary {trees} --- HELP --- TeX encountered an unknown command name. You probably misspelled the name. If this message occurs when a LaTeX command is being processed, the command is probably in the wrong place---for example, the error can be produced by an \item command that's not inside a list-making environment. The error can also be caused by a missing \documentclass command. What am I missing here? I'd like to be able to keep my org stuff separate from the Latex source, which org-mode seems to do nicely. But then it has to run properly too. . . . LB --047d7b6d98de2a45eb0514a8e0f9 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
I'm following the Latex howto of org-mode babel. = Here's the snippet from the howto I've got in a separate .org file = (see bottom of howto page):

#+LATEX_HEADER: \usepa= ckage{tikz}

First execute the second code block, t= o define the convenience macro
and to set the required new variab= les in ob-latex.el.=C2=A0 Then export to
HTML and to pdf to see t= he tree exported as an SVG image and as
embedded tikz respectivel= y.

* Tikz test
Here's a tree, export= ed to both html and pdf.

#+header: :file (by-backe= nd (html "tree.svg") (t 'nil))
#+header: :imagemagi= ck
#+header: :results (by-backend (pdf "latex") (t &quo= t;raw"))
#+header: :tangle yes
#+begin_src latex
=C2=A0 \usetikzlibrary{trees}
=C2=A0 \begin{tikzpicture}=
=C2=A0 =C2=A0 \node [circle, draw, fill=3Dred!20] at (0,0) {1}
=C2=A0 =C2=A0 child { node [circle, draw, fill=3Dblue!30] {2}
=C2=A0 =C2=A0 =C2=A0 child { node [circle, draw, fill=3Dgreen!30] {3}= }
=C2=A0 =C2=A0 =C2=A0 child { node [circle, draw, fill=3Dyellow= !30] {4} }};
=C2=A0 \end{tikzpicture}
#+end_src

* COMMENT setup
#+header: :tangle yes
#+begin_src emacs-lisp :results silent
=C2=A0 (setq org-babel-la= tex-htlatex "htlatex")
=C2=A0 (defmacro by-backend (&am= p;rest body)
=C2=A0 =C2=A0 `(case (if (boundp 'backend) (org-= export-backend-name backend) nil) ,@body))
#+end_src
This doesn't really produce a .svg of the tree as advertis= ed, but exporting to Latex does produce it just fine.

My real confusion starts when I try to tangle the babel code blocks= . The C-c C-v t command produces two separate files just fine, a .tex and .= el, but then if I try to Run Latex on the .tex file just by itself it gives= an error. Here's what the org-mode tangle produces:

\usetikzlibrary{trees}
\begin{tikzpicture}
=C2= =A0 \node [circle, draw, fill=3Dred!20] at (0,0) {1}
=C2=A0 child= { node [circle, draw, fill=3Dblue!30] {2}
=C2=A0 =C2=A0 child { = node [circle, draw, fill=3Dgreen!30] {3} }
=C2=A0 =C2=A0 child { = node [circle, draw, fill=3Dyellow!30] {4} }};
\end{tikzpicture}

And here's the error log after I try to run it = by itself in Emacs:

. . .entering extended mode
=C2=A0restricted \write18 enabled.
=C2=A0file:line:error = style messages enabled.
=C2=A0%&-line parsing enabled.
<= div>**\input prac2.tex
(./prac2.tex
./prac2.tex:2: Unde= fined control sequence.
l.2 \usetikzlibrary
=C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0{trees}
The control sequence at the end of the top line
of your error m= essage was never \def'ed. If you have
misspelled it (e.g., `\= hobx'), type `I' and the correct
spelling (e.g., `I\hbox&= #39;). Otherwise just continue,
and I'll forget about whateve= r was undefined.
Another version (from C-c `) produces this error= message:

ERROR: Undefined control sequence.
=

--- TeX said ---
l.2 \usetikzlibrary
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0{tre= es}
--- HELP ---
TeX encountered an unknown command nam= e. You probably misspelled the
name. If this message occurs when = a LaTeX command is being processed,
the command is probably in th= e wrong place---for example, the error
can be produced by an \ite= m command that's not inside a list-making
environment. The er= ror can also be caused by a missing \documentclass
command.
=

What am I missing here? I'd like to be able to keep= my org stuff separate from the Latex source, which org-mode seems to do ni= cely. But then it has to run properly too. . . .

L= B
--047d7b6d98de2a45eb0514a8e0f9--