Problems of preview-latex
preview-latex is a handy function provided by AUCTeX for directly rendering LaTeX equations and inserted figures in a Emacs buffer under the latex-mode. lstlistings is LaTeX package for highlighting source code. According to my experience, when lstlistings package is used, preview-latex have the following problems, some of which can be overcome actually.
-
When
\lstlistofalgorithmsappears at the end of a LaTeX document,preview-latexwill get stuck and consume 100% CPU.Solution: remove
sectionsfrom the variablepreview-default-option-listinpreview-latex, which will stop processing\lstlistofalgorithms. - Preview of math symbols in a
lstlistingsalgorithm is a mess. - Math symbols in an environment introduced by
ntheorem, such asTheorem,Definition,Remark, etc., will become bold face in the preview. -
A
\mboxcommand appearing in thepostbreakproperty oflstlistingsconfiguration will makepreview-latexfail.As shown below, the
\mboxcommand should be replaced with\hbox. The difference between\mboxand\hboxis here.\makeatletter \@ifclassloaded{beamer}{ \newsavebox\redarrow \sbox\redarrow{\raisebox{0ex}[0ex][0ex]{\ensuremath{\color{red}\hookrightarrow\space}}} \lstset{postbreak=\usebox\redarrow} }{\lstset{postbreak=\mbox{\textcolor{red}{$\hookrightarrow$}\space}}} \makeatother