emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Andreas Leha <andreas.leha@med.uni-goettingen.de>
To: emacs-orgmode@gnu.org
Subject: Re: patch for latex->tikz
Date: Thu, 18 Jul 2013 00:31:50 +0200	[thread overview]
Message-ID: <87ip08es2x.fsf@med.uni-goettingen.de> (raw)
In-Reply-To: 87r4ewj1o6.fsf@gmail.com

Hi Eric,

Eric Schulte <schulte.eric@gmail.com> writes:

> Andreas Leha <andreas.leha@med.uni-goettingen.de> 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
    <<picturecontents>>
#+end_src

# can be evaluated to pdf/svg/imagemagick
#+begin_src latex
  \begin{tikzpicture}
    <<picturecontents>>
  \end{tikzpicture}
#+end_src
--8<---------------cut here---------------end--------------->8---


Regards,
Andreas

  reply	other threads:[~2013-07-17 22:32 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-17 21:37 patch for latex->tikz Andreas Leha
2013-07-17 21:51 ` Eric Schulte
2013-07-17 22:31   ` Andreas Leha [this message]
2013-07-18  8:49 ` Eric S Fraga

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ip08es2x.fsf@med.uni-goettingen.de \
    --to=andreas.leha@med.uni-goettingen.de \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).