> On Jan 10, 2025, at 10:59 AM, Rens Oliemans <ha...@rensoliemans.nl> wrote: > > Richard H Stanton <rhstan...@berkeley.edu> writes: > >> Here’s an example: >> >> #+begin_src python :results output replace raw >> print("a") >> #+end_src >> >> Every time I run this code block, I get another line containing “a”. If I >> don't use the raw option, e.g., >> >> #+begin_src python :results output >> print("a") >> #+end_src >> >> the multiple-output problem goes away, but now it appears as >> >> #+RESULTS: >> : a >> >> ... >> >> But is there a “preferred” way to output arbitrary text (e.g., LaTeX >> equations) from Python code blocks so that they compile fine *and* don’t >> append? > > Generally, I don't know. Perhaps someone else can enlighten us on this part. > > Since you are using \begin{equation} which is definitively LaTeX-specific, you > can always use the "latex" header option, say > > #+begin_src python :results output latex > print("a") > #+end_src > > #+RESULTS: > #+begin_export latex > a > #+end_export > > This is more or less what you had with your flushleft drawer, so I'm not sure > whether this fixes anything or not.
If you do this, the output doesn’t show if you export to HTML. flushleft and the :results: drawer both seem to work fine exporting to both PDF and HTML.