Hi,

the kind of output I want to include is
-----
\begin{tikzpicture}
\useasboundingbox (0cm,0cm) rectangle ++(16cm,9cm);
\pie[sum=auto,pos={2cm,7cm},radius=1.5]{19/PDF,7/}
\pie[sum=auto,pos={6cm,7cm},radius=1.5]{14/Lua,12/}
\pie[sum=auto,pos={10cm,7cm},radius=1.5]{9/Xe,17/}
\pie[sum=auto,pos={4cm,3.50cm},radius=1.5]{9/PDF+Lua,17/}
\end{tikzpicture}
----
But it doesn't need to be that complex. Sometimes it is just a string with
a double \n to
make sure you start a new paragraph...

Anyhow, just asking to see if it makes sense or not. I think src_python is
really cool even in its current definition.

I can stay with my snippet that produces

#+BEGIN_SRC python :session :results output raw :exports results
<<code here>>
#+END_SRC
#+RESULTS:

and move forward.

/PA


On Fri, 26 Jun 2026 at 16:05, Leo Butler <[email protected]> wrote:

> Pedro,
>
> IIUC, you are exporting to a LaTeX-based backend, correct?
>
> In that case, I would have the code define and print a LaTeX macro, like
> so:
>
> pic1="""\def\picOne{...}"""
> print(pic1)
>
> (not sure of the python syntax, but you get the idea).
>
> Change the src block header:
>
> #+BEGIN_SRC python :session :exports results :results verbatim :wrap
> "export latex"
>
> Then, in the document body, you can use the LaTeX macro:
> @@latex:\picOne{}@@
>
> Leo
>
>
> On Fri, Jun 26 2026, Pedro Andres Aranda Gutierrez <[email protected]>
> wrote:
>
> > Hi Derek
> >
> > -------
> >
> > #+BEGIN_SRC python :session :exports none
> > # These would be the result of my processing of survey.xlsx
> > pic1="""\begin{tikzpicture}
> > \begin{loglogaxis}[
> >     xlabel={\textsc{Dof}},
> >     ylabel={$L_2$ Error},
> >     grid=major,
> > ]
> >     % see above for this macro:
> >     \plotcoords
> > \end{loglogaxis}
> > \end{tikzpicture}
> > """
> >
> > pic2 = """\begin{tikzpicture}
> > \begin{loglogaxis}[
> >     grid=both,
> >     tick align=outside,
> >     tickpos=left,
> > ]
> >     \addplot coordinates {
> >         (100,1e-4) (500,1e-5) (1000,3e-6)
> >     };
> >     \addplot coordinates {
> >         (100,1e-5) (500,4e-6) (1000,2e-6)
> >     };
> > \end{loglogaxis}
> > \end{tikzpicture}
> > """
> > #+END_SRC
> >
> >
> > * The different =pgfplots=
> >
> > So here I would like to insert one of them:
> >
> > src_python[:session]{pic1}
> >
> > And then the other one:
> >
> > src_python[:session]{pic2}
> >
> > ----
> >
> > Of course, you could
> >
> > #+BEGIN_SRC python :session :results output  :exports results
> > print(pic1)
> > #+END_SRC
> >
> > #+RESULTS:
> >
> > But the inlined version is much more compact.
> >
> > Best, /PA
> >
> >
> > On Fri, 26 Jun 2026 at 05:40, Derek Chen-Becker <[email protected]>
> > wrote:
> >
> >> Could you provide an example? For multi-line output, would we need to
> >> define a delimiter to demarcate separate outputs, or am I
> misunderstanding
> >> something?
> >>
> >> Thanks,
> >>
> >> Derek
> >>
> >> On Thu, Jun 25, 2026 at 11:01 AM Pedro Andres Aranda Gutierrez <
> >> [email protected]> wrote:
> >>
> >>> Hi
> >>>
> >>> I was just wondering whether we could find a way to add multi-line
> output
> >>> in inlined code.
> >>>
> >>> Just as an example:
> >>> In the presentation I gave on the LaTeX survey I, I needed to load the
> >>> Excel file into my Python for every graph. I'd like to be able to
> >>> pre-generate all graphs, which are multi-line Latex TiKZ code, in a
> common
> >>> code block and then place the graphs in their frame.
> >>>
> >>> Best, /PA
> >>> --
> >>> Fragen sind nicht da, um beantwortet zu werden,
> >>> Fragen sind da um gestellt zu werden
> >>> Georg Kreisler
> >>>
> >>> "Sagen's Paradeiser" (ORF: Als Radiohören gefährlich war) => write BE!
> >>> Year 2 of the New Koprocracy
> >>>
> >>>
> >>
> >> --
> >> +---------------------------------------------------------------+
> >> | Derek Chen-Becker                                             |
> >> | GPG Key available at https://keybase.io/dchenbecker and       |
> >> | https://pgp.mit.edu/pks/lookup?search=derek%40chen-becker.org |
> >> | Fngrprnt: EB8A 6480 F0A3 C8EB C1E7  7F42 AFC5 AFEE 96E4 6ACC  |
> >> +---------------------------------------------------------------+
> >>
> >>
>
> --
> ---
> Best regards,
> Dr Butler



-- 
Fragen sind nicht da, um beantwortet zu werden,
Fragen sind da um gestellt zu werden
Georg Kreisler

"Sagen's Paradeiser" (ORF: Als Radiohören gefährlich war) => write BE!
Year 2 of the New Koprocracy

Reply via email to