The context
The following org
buffer
* Random name
This is an equation
\begin{equation}
x = a + b
\end{equation}
This is a box
\begin{tcolorbox}
a
\end{tcolorbox}
is previewed as
The question
Just as it is possible to preview the content of a equation
environment. Is it possible to preview the content of the tcolorbox
envionment?
It seems that Emacs is not loading the tcolorbox
environment. Is there any way I can make Emacs load a given LaTeX package? so that when previewing a LaTeX code snippet that uses the tcolorbox
environment, the actual content is displayed.
Additional information
Have you installed the tcolorbox
package?
Yes. I can confirm this because I've compiled several documents that uses the tcolorbox
environment with pdflatex
without any problems.
Have you checked the variable org-latex-packages-alist
contains the tcolorbox
package?
Yes. When describing the variable, I get the following value: (("" "tcolorbox" t))
What's the value of the variable org-preview-latex-default-process
?
Its value is dvipng
. This is the default value and I've not changed it.
If you add #+LATEX_HEADER: \usepackage{tcolorbox}
at the top of your Org mode file and export to PDF. Do you see the box?
Yes, I can see the box in the generated PDF file but still can't see when executing org-latex-preview
within a tcolorbox
environment. tcolorbox
es are still being previewed as tiny empty boxes.
I tested this when org-latex-packages-alist
was equal to nil
.
if you try to export without the header, is there a \usepackage{tcolorbox}
in the generated .tex
file?
Without the header and with org-latex-packages-alist
equal to nil
, there is no \usepackage{tcolorbox}
. However, the environment tcolorbox
is used within the .tex
file. In the resulting PDF file, only the text within the tcolorbox
is rendered as normal text but no box is rendered.
Without the header and with org-latex-packages-alist
equal to (("" "tcolorbox" t))
, \usepackage{tcolorbox}
does appears within the document. In the resulting PDF file, the tcolorbox
environment is properly displayed (i.e. its content and the actual box).
Post screenshoots of the tiny empty box
Actually, it is not a tiny empty box. I wrote that because I tested it with a black background. Actually, the text within the tcolorbox
is rendered in the preview but the box is not. See how the following Org file is previewed
#+LATEX_HEADER: \usepackage{tcolorbox}
#+LATEX_HEADER: \usepackage{lipsum}
This is random text.
\begin{tcolorbox}
a b c d
\end{tcolorbox}
This is random text
\begin{tcolorbox}
\lipsum[1]
\end{tcolorbox}
This is random text.
Preview and resulting PDF of the Org mode file shown above
This was tested when these variables had the following values
org-latex-packages-alist
:nil
org-preview-latex-default-process
:dvipng
dvipng
(I useimagemagick
as my org-preview-latex-default-process). I'll check some more when I have some time.(setq org-preview-latex-default-process 'imagemagick)
but now previewing can't occur because I'm getting the following error:org-compile-file: File "/tmp/orgtexLO3Agf.png" wasn’t produced. Please adjust ‘imagemagick’ part of ‘org-preview-latex-process-alist’.
I do haveimagemagick
installed in my system.imagemagick
instead ofdvipng
(by executing(setq org-preview-latex-default-process 'imagemagick)
) and then modify the/etc/ImageMagick-7/policy.xml
file as stated in an answer to the question. Thank you so much for your help @NickD. Please edit your answer so I can mark it as accepted answer.