当我尝试使用此答案中的代码将文本放置在 3D Tikz 图片中的“画布”上时遇到问题:TiKZ:如何定义新的 2D 画布。首先,当文本放置在范围环境中时,它根本不会在画布上排版(即,没有预期的 3D 效果)。因此,我对每个文本节点分别使用了画布选项。但是,虽然这会产生 3D 效果,但文本并没有放置在我期望的位置。请参阅下面的 MWE。作为参考,我已包含一个正确放置的 x' 轴、一个 y' 轴和一个正方形。
有人能解释一下出了什么问题以及如何解决吗?
\documentclass{article}
\usepackage{tikz}
\usepackage{tikz-3dplot}
\makeatletter
\tikzoption{canvas is plane}[]{\@setOxy#1}
\def\@setOxy O(#1,#2,#3)x(#4,#5,#6)y(#7,#8,#9)%
{\def\tikz@plane@origin{\pgfpointxyz{#1}{#2}{#3}}%
\def\tikz@plane@x{\pgfpointxyz{#4}{#5}{#6}}%
\def\tikz@plane@y{\pgfpointxyz{#7}{#8}{#9}}%
\tikz@canvas@is@plane
}
\makeatother
\begin{document}
\tdplotsetmaincoords{135}{45}
\begin{tikzpicture}[tdplot_main_coords]
\draw[->] (0,0,0) -- (5,0,0) node[anchor=south west]{$x$};
\draw[->] (0,0,0) -- (0,5,0) node[anchor=west]{$y$};
\draw[->] (0,0,0) -- (0,0,5) node[anchor=south]{$z$};
\begin{scope}[canvas is plane={O(1.5,0,2.5)x(2.4487,0,2.8162)y(1.1838,0,3.4487)}]
\draw[->] (0,0) -- (2,0) node[right] {$x'$};
\draw[->] (0,0) -- (0,2) node[right] {$y'$};
\draw[fill] (1,1) rectangle (2,2);
\node at (0,-2) {Should be on canvas};
\end{scope}
\node[canvas is plane={O(1.5,0,2.5)x(2.4487,0,2.8162)y(1.1838,0,3.4487)}] at (-1,0) {Should};
\node[canvas is plane={O(1.5,0,2.5)x(2.4487,0,2.8162)y(1.1838,0,3.4487)}] at (0,0) {follow};
\node[canvas is plane={O(1.5,0,2.5)x(2.4487,0,2.8162)y(1.1838,0,3.4487)}] at (1,0) {$x'$-axis};
\end{tikzpicture}
\end{document}