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