Re: Tikz ugly hack

2022-10-28 Thread edgar

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!




Re: Tikz ugly hack

2022-10-26 Thread Fraga, Eric
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


Tikz ugly hack

2022-10-26 Thread edgar

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