From mboxrd@z Thu Jan 1 00:00:00 1970 From: Lawrence Bottorff Subject: Re: Tangled Latex code gives error Date: Sun, 26 Apr 2015 21:45:31 -0400 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=e89a8fb20796bd76f70514aae67f Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:33473) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YmY74-00085f-QY for emacs-orgmode@gnu.org; Sun, 26 Apr 2015 21:45:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YmY73-0004Pb-AA for emacs-orgmode@gnu.org; Sun, 26 Apr 2015 21:45:34 -0400 Received: from mail-pa0-x22d.google.com ([2607:f8b0:400e:c03::22d]:33772) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YmY72-0004PN-Sb for emacs-orgmode@gnu.org; Sun, 26 Apr 2015 21:45:33 -0400 Received: by pacwv17 with SMTP id wv17so90410339pac.0 for ; Sun, 26 Apr 2015 18:45:31 -0700 (PDT) In-Reply-To: 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 --e89a8fb20796bd76f70514aae67f Content-Type: text/plain; charset=UTF-8 . . . okay, I realize that a viable Latex document has many preliminary commands. Here's a "working" version of my tangled code \documentclass{article} \usepackage{tikz} \usetikzlibrary{trees} \begin{document} \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{document} I guess I need to know where to begin to get the "default" org-mode Latex export functionality for Latex babel tangling. But then maybe I'm barking up the wrong tree. One of the hardest things about learning org-mode is finding out what the "best practice" of something really is. On Sun, Apr 26, 2015 at 7:20 PM, Lawrence Bottorff wrote: > 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 > --e89a8fb20796bd76f70514aae67f Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
. . . okay, I realize that a viable Latex document has man= y preliminary commands. Here's a "working" version of my tang= led code

\documentclass{article}
\usepack= age{tikz}
\usetikzlibrary{trees}
\begin{document}
=

\begin{tikzpicture}
=C2=A0 \node [circle, dra= w, 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, fi= ll=3Dgreen!30] {3} }
=C2=A0 =C2=A0 child { node [circle, draw, fi= ll=3Dyellow!30] {4} }};
\end{tikzpicture}
\end{do= cument}

I guess I need to know where to begin = to get the "default" org-mode Latex export functionality for Late= x babel tangling.

But then maybe I'm barking u= p the wrong tree. One of the hardest things about learning org-mode is find= ing out what the "best practice" of something really is.

On Sun, Apr 26= , 2015 at 7:20 PM, Lawrence Bottorff <borgauf@gmail.com> wro= te:
I'm followi= ng 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
<= div>and to set the required new variables in ob-latex.el.=C2=A0 Then export= to
HTML and to pdf to see the tree exported as an SVG image and = as
embedded tikz respectively.

* Tikz te= st
Here's a tree, exported to both html and pdf.
#+header: :file (by-backend (html "tree.svg") (t = 9;nil))
#+header: :imagemagick
#+header: :results (by-b= ackend (pdf "latex") (t "raw"))
#+header: :ta= ngle yes
#+begin_src latex
=C2=A0 \usetikzlibrary{trees= }
=C2=A0 \begin{tikzpicture}
=C2=A0 =C2=A0 \node [circl= e, 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 { no= de [circle, draw, fill=3Dgreen!30] {3} }
=C2=A0 =C2=A0 =C2=A0 chi= ld { node [circle, draw, fill=3Dyellow!30] {4} }};
=C2=A0 \end{ti= kzpicture}
#+end_src

* COMMENT setup
#+header: :tangle yes
#+begin_src emacs-lisp :results sile= nt
=C2=A0 (setq org-babel-latex-htlatex "htlatex")
=C2=A0 (defmacro by-backend (&rest body)
=C2=A0 =C2=A0 = `(case (if (boundp 'backend) (org-export-backend-name backend) nil) ,@b= ody))
#+end_src

This doesn't really = produce a .svg of the tree as advertised, but exporting to Latex does produ= ce 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-mo= de 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 enabl= ed.
=C2=A0file:line:error style messages enabled.
=C2= =A0%&-line parsing enabled.
**\input prac2.tex
(./p= rac2.tex
./prac2.tex:2: Undefined 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 t= he top line
of your error message was never \def'ed. If you h= ave
misspelled it (e.g., `\hobx'), type `I' and the corre= ct
spelling (e.g., `I\hbox'). Otherwise just continue,
<= div>and I'll forget about whatever was undefined.
Another ver= sion (from C-c `) produces this error message:

ERR= OR: 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{trees}
--- HELP ---
= TeX encountered an unknown command name. You probably misspelled the
<= div>name. If this message occurs when a LaTeX command is being processed,
the command is probably in the wrong place---for example, the erro= r
can be produced by an \item command that's not inside a lis= t-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

--e89a8fb20796bd76f70514aae67f--