From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andreas Leha Subject: Re: patch for latex->tikz Date: Thu, 18 Jul 2013 00:31:50 +0200 Message-ID: <87ip08es2x.fsf@med.uni-goettingen.de> References: <87zjtkeul6.fsf@med.uni-goettingen.de> <87r4ewj1o6.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:60721) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UzaGY-0008Lm-OP for emacs-orgmode@gnu.org; Wed, 17 Jul 2013 18:32:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UzaGX-0006We-Hg for emacs-orgmode@gnu.org; Wed, 17 Jul 2013 18:32:10 -0400 Received: from plane.gmane.org ([80.91.229.3]:52182) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UzaGX-0006VK-AK for emacs-orgmode@gnu.org; Wed, 17 Jul 2013 18:32:09 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1UzaGV-0006hj-Og for emacs-orgmode@gnu.org; Thu, 18 Jul 2013 00:32:07 +0200 Received: from vpn-2025.gwdg.de ([134.76.2.25]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 18 Jul 2013 00:32:07 +0200 Received: from andreas.leha by vpn-2025.gwdg.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 18 Jul 2013 00:32:07 +0200 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 Hi Eric, Eric Schulte writes: > Andreas Leha writes: > >> Hi all, >> >> attached is a small patch that makes it possible to 'evaluate' latex >> source blocks to tikz files. > > Applied, thanks. > >> >> When the :file header argument has a value ending in '.tikz' the >> content of the body of the source block will be copied into the >> resulting tikz file. This makes handling of tikz figures with >> captions easier. >> >> Here is a use-case: > [...] >> This example works well besides some weird scaling/placement issue. >> > > The best way I've found to deal with scaling/placement of raw or inline > tikz is to use the subcaption and adjustbox packages as in the following > example. > > % latex > \begin{figure} > \centering > \begin{minipage}[b]{0.32\linewidth} > \adjustbox{width=1.0\linewidth}{ > \begin{tikzpicture} > % ... > \end{tikzpicture} > } > \subcaption{\small part 1} > \end{minipage} > \begin{minipage}[b]{0.32\linewidth} > \adjustbox{width=1.0\linewidth}{ > \begin{tikzpicture} > % ... > \end{tikzpicture} > } > \subcaption{\small part 2} > \end{minipage} > \begin{minipage}[b]{0.32\linewidth} > \adjustbox{width=1.0\linewidth}{ > \begin{tikzpicture} > % ... > \end{tikzpicture} > } > \subcaption{\small part 3} > \end{minipage} > \caption{Example with three sub-parts} > \label{fig:example} > \end{figure} thanks for the pointer. I was not aware of the adjustbox package before. Definitely interesting. Playing with it I found the flaw in my patch. The inclusion of [[foo.tikz]] is wrapped in \begin{tikzpicture} ... \end{tikzpicture} already during LaTeX export. So, exporting my example to latex gives a nested tikzpicture. There is nothing wrong with that, but the outer tikzpicture has these scaling options, hence the wrong placement/scaling. The code block that is going to tikz should, thus, *not* contain the \begin{tikzpicture} and \end{tikzpicture} directives. That might not render my patch completely useless, but limits its use at least. I was hoping for one and the same latex code block to be evaluated to tikz/pdf/svg/imagemagick giving (more ore less) the same resulting image in each. In the moment that is not the case. To clarify this: --8<---------------cut here---------------start------------->8--- # can be evaluated to tikz (to export to latex) #+begin_src latex <> #+end_src # can be evaluated to pdf/svg/imagemagick #+begin_src latex \begin{tikzpicture} <> \end{tikzpicture} #+end_src --8<---------------cut here---------------end--------------->8--- Regards, Andreas