答案1
使用yslant
和transform shape
:
\documentclass[tikz, border=2mm]{standalone}
\usetikzlibrary{calc} % for the middle of a segment (only for the demo code)
\usepackage{graphicx}
\begin{document}
\begin{tikzpicture}[yslant=0.5]
\coordinate (A) at (0,0);
\coordinate (B) at (5,3);
\draw (A) -- (A-|B)
node[midway, transform shape, above] {The quick brown fox}
node[midway, transform shape, below, text width=5em, align=center]
{jumped over the lazy dog.}
-- (B) node[midway, transform shape, right] {$Ax = B$}
-- (A|-B) -- cycle;
\node[transform shape] at ($(A)!0.5!(B)$) {\includegraphics[width=2cm]
{example-image-duck}};
\end{tikzpicture}
\end{document}
默认情况下,节点内容不受转换的影响(如yslant=0.5
这里定义的转换)。这是transform shape
使转换应用于节点内容的选项。当然,如果你想要transform shape
应用于所有节点,你可以用以下方式开始图片:
\begin{tikzpicture}[yslant=0.5, nodes={transform shape}]
为了进行更细粒度的控制,您可以使用scope
环境,如下所示:
\begin{scope}[nodes={transform shape}]
\node at ($(A)!0.5!(B)$) {\includegraphics[width=2cm] {example-image-duck}};
\end{scope}
如果我们使用它并且不应用于transform shape
该图片的任何其他节点,则输出将变为:
答案2
您可以使用tikz
的3d
库,请参阅pgf
手册 v3.1.5b第40条
例如
\documentclass[tikz]{standalone}
\usetikzlibrary{3d}
\begin{document}
\begin{tikzpicture}[]
\draw[->] (0,0,0) -- (1,0,0);
\draw[->] (0,0,0) -- (0,1,0);
\draw[->] (0,0,0) -- (0,0,1);
\begin{scope}[canvas is xy plane at z=0.5,transform shape]
\node (0,0) {S};
\end{scope}
\begin{scope}[canvas is xz plane at y=0.5,transform shape]
\node (0,0) {S};
\end{scope}
\begin{scope}[canvas is yz plane at x=0.5,transform shape]
\node (0,0) {S};
\end{scope}
\end{tikzpicture}
\end{document}