\documentclass[a4paper]{article} % \usepackage[german]{babel} \usepackage[T2A]{fontenc} \usepackage[latin1]{inputenc} \usepackage[showlabels,sections,floats,textmath,displaymath]{preview} %=========================================== \usepackage{todonotes} \newcommand{\td}[1]{\todo%[linecolor=red!60, color=green!40, fancyline]% {#1}} % {\tiny{#1}}} %=========================================== \textwidth 160mm \textheight 240mm \topmargin -20mm \oddsidemargin -5mm % \title{The conflict between \texttt{preview-latex} and \texttt{todonotes}} \author{\textbf{T.~H.~PhyZZilla}} \date{September 31, 2017} \begin{document} \maketitle \section{Introduction} In my letter of September 24 to \textsf{GNU bug Tracking System
} I have reported the following issue. When trying to preview the emacs buffer the images were generated only for in-line items. Section headings and display equations stayed with "no-way" sign. However it was possible to preview each of them separately with the help of either "preview at point" or of "preview environment" and "regenerate" functions. It turned out that in my case the reason was the conflict with the \texttt{todonotes} package. Below I present an example of the conflict. \section{The ``Scientific'' Section} The common opinion is that the two great equations of twentieth century are those by Planck and Einstein. The first of them was proposed in 1900 and marked the origin of \emph{Quantum mechanics.} \begin{equation} \label{eq:1} E_P = h \nu . \end{equation} Here $E_P$ is the energy quantum of an oscillator, $\nu$ is the oscillator frequency and $h$ is the famous Planck's constant.% % \todo{Reference!}\\ (*) \emph{Note the non-offending} \texttt{todo note} \emph{ in the margin.} Syntax \verb'\todo{command}' The second of them was published in 1905 by Einstein and was the cornerstone of the Special Relativity theory. \begin{equation} \label{eq:2} E_E = m\, c^2 . \end{equation} It relates the energy of a body at rest $E_E$ to its mass $m$. Einstein postulated that the speed of light $c$ is a fundamental physical constant.% \todo[fancyline]{Reference!}\\ (*) \emph{This is the example of offending} \texttt{todo note}. Syntax: \verb'\todo[fancyline]{command}' Let us discuss some nontrivial consequences of the two indisputable facts mentioned above. \todo[inline]{\centerline{Invent something by tomorrow!}} \noindent (*) \emph{Another non-offending} \texttt{todo note}. Syntax: \verb'\todo[inline]{command}' \section{Discussion} The \verb'\todo' commands allow \LaTeX\ to process the file ``as it is''. However the \texttt{preview-latex} while being successful at every point and environment separately, fails to generate the preview of the whole buffer. Commenting the \verb'\todo' command with \texttt{[fancyline]} option after Eqn.~2 solves the problem at the price of excluding the note from the draft as a whole. \section{Acknowledgment} The author is grateful to everybody who will find his \LaTeX-discovery useful. \end{document}