emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Tikz ugly hack
@ 2022-10-26  8:52 edgar
  2022-10-26  9:58 ` Fraga, Eric
  0 siblings, 1 reply; 3+ messages in thread
From: edgar @ 2022-10-26  8:52 UTC (permalink / raw)
  To: emacs-orgmode

Dear Org users,

I just want to share a way to combine Tikz (LaTeX) with figures (svg, 
png...). This may be needed to add elements (e.g. annotations) to your 
figure. The figure may still be exported with other back-ends (without 
annotations). If you know of a better way of doing this, please, let me 
know. Thanks.

#+latex_header: \usepackage{adjustbox,tikz}
#+latex_header: \newcommand*{\DrawGrid}{\draw[step=.2cm,help lines] 
(current bounding box.south west) grid (current bounding box.north 
east);}
#+latex_header: \newcommand*{\DrawBoundingBox}[2]{% 
https://tex.stackexchange.com/a/542819
#+latex_header:     \draw [red, very thick, rounded corners]
#+latex_header:     ([shift={(#1)}]current bounding box.south west)
#+latex_header:     rectangle
#+latex_header:     ([shift={(#2)}]current bounding box.north east);}
#+begin_export latex
\begin{tikzpicture}
   % left bottom right top
   \node {\adjustbox{height=0.7\textheight,trim=45.6mm 0mm 155mm 20mm, 
clip=true}{
#+end_export
   #+attr_latex: :height "" :width "" :options "" :center nil
   [[file:../diagram.svg]]
#+begin_export latex
   }};
   \DrawBoundingBox{5.7cm,0.71cm}{-0.1cm,-3.6cm}
   % \DrawGrid
\end{tikzpicture}
#+end_export


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Tikz ugly hack
  2022-10-26  8:52 Tikz ugly hack edgar
@ 2022-10-26  9:58 ` Fraga, Eric
  2022-10-28  8:45   ` edgar
  0 siblings, 1 reply; 3+ messages in thread
From: Fraga, Eric @ 2022-10-26  9:58 UTC (permalink / raw)
  To: edgar; +Cc: emacs-orgmode@gnu.org

On Wednesday, 26 Oct 2022 at 08:52, edgar wrote:
> I just want to share a way to combine Tikz (LaTeX) with figures (svg,
> png...).

I wonder if, instead of a new LaTeX command you create a new environment
which you can then invoke using org special blocks?  For instance,

#+begin_BoundingBox

#+attr_latex: :height 1cm
[[image file]]

#+end_BoundingBox

where you have

#+latex_header: \newenvironment{BoundingBox}{
#+latex_header: % commands before the body of the environment
#+latex_header: \begin{tikzpicture}
#+latex_header: }
#+latex_header: {
#+latex_header: % command after the body of the environment
#+latex_header: \end{tikzpicture}
#+latex_header: }

-- 
: Eric S Fraga, with org release_9.5.5-1028-gcd835d in Emacs 29.0.50

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Tikz ugly hack
  2022-10-26  9:58 ` Fraga, Eric
@ 2022-10-28  8:45   ` edgar
  0 siblings, 0 replies; 3+ messages in thread
From: edgar @ 2022-10-28  8:45 UTC (permalink / raw)
  To: Org Mode List

On 2022-10-26 09:58, Fraga, Eric wrote:
> I wonder if, instead of a new LaTeX command you create a new 
> environment
> which you can then invoke using org special blocks?  For instance,
> 
> #+begin_BoundingBox
> 
> #+attr_latex: :height 1cm
> [[image file]]
> 
> #+end_BoundingBox
> 
> --- snip 8< ---

Oh, I don't know how to do that, but it's good to know that at some 
point I can create it. Thanks!


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-10-28  8:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-26  8:52 Tikz ugly hack edgar
2022-10-26  9:58 ` Fraga, Eric
2022-10-28  8:45   ` edgar

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).