![AUCTeX 预览渲染 tikzpicture 错误](https://linux22.com/image/474340/AUCTeX%20%E9%A2%84%E8%A7%88%E6%B8%B2%E6%9F%93%20tikzpicture%20%E9%94%99%E8%AF%AF.png)
我有以下乳胶文档:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{angles}
\usetikzlibrary{calc}
\usetikzlibrary{quotes}
\begin{document}
\begin{tikzpicture}
\coordinate (o) at (0, 0);
\draw[thick, ->] (o) -- (3, 5.2) coordinate (b) node[left=2mm] {$b$};
\draw[thick, ->] (o) -- (7, 2) coordinate (a) node[right=1mm] {$a$};
\coordinate (p) at ($(0,0)!(b)!(a)$);
\draw[dashed] (p) -- (b);
\draw[thick, ->] (o) -- (p) node[below] {$p$};
\end{tikzpicture}
\end{document}
在 Emacs 中运行 AUCTeXpreview-at-point
会生成以下图像:
虚线和矢量p
绘制不正确。运行后lualatex example.tex
会创建以下 pdf:
如何使用 AUCTeX 预览生成正确的预览图片?
另外:如何将 TikZ 图片的字体颜色设置为白色?
版本:
- Emacs:29.2
- AUCTeX:14.0.3
答案1
preview
并且tikz
运行效果不佳。我建议您将其导出tikzpicture
到外部文件中,然后standalone-test.tex
运行pdflatex
:
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{angles}
\usetikzlibrary{calc}
\usetikzlibrary{quotes}
\begin{document}
\begin{tikzpicture}
\coordinate (o) at (0, 0);
\draw[thick, ->] (o) -- (3, 5.2) coordinate (b) node[left=2mm] {$b$};
\draw[thick, ->] (o) -- (7, 2) coordinate (a) node[right=1mm] {$a$};
\coordinate (p) at ($(0,0)!(b)!(a)$);
\draw[dashed] (p) -- (b);
\draw[thick, ->] (o) -- (p) node[below] {$p$};
\end{tikzpicture}
\end{document}
%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% End:
然后将其重新包含到原始文件中,如下所示:
\documentclass{article}
\usepackage{graphicx}
\begin{document}
\noindent
\includegraphics[page=1]{standalone-test}
\end{document}
%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% End:
答案2
这预览该包存在 TikZ 计算语法问题。
当我将其添加到标题时,TikZ 图片可以正确呈现:
\AtBeginEnvironment{tikzpicture}{\catcode`$=3 } % $
正如这里提到的:https://lists.gnu.org/archive/html/bug-auctex/2020-05/msg00004.html