如何透過旋轉包旋轉整個 tikzpicture 時保持某些文字直立

如何透過旋轉包旋轉整個 tikzpicture 時保持某些文字直立

我會將整個 tikzpicture 旋轉特定角度。我將包rotating用於此目的,如中所述https://tex.stackexchange.com/a/199471/。但問題是我想保持插入的文字直立。例如,在下圖中,符號“u”已傾斜。有一個相關的問題如何旋轉節點的位置但不旋轉節點內的文本但它不使用“旋轉”包。動機是,在繪製圖片時,將圖片垂直繪製更容易,然後旋轉它,因為計算更容易。

準確地說,我希望節點與文字一起旋轉,但文字看起來是直立的。

\documentclass{article}
\usepackage{tikz}
\usepackage{rotating}

\begin{document}
 \begin{turn}{-37}
\begin{center}
\begin{tikzpicture}[scale=1]
\draw [->] (3.5, 1.5)-- (4.25, 3.75); 
\node at (4.45, 3.75) {$u$}; 
\end{tikzpicture}
\end{center}
\end{turn}

\end{document} 

答案1

標題中問題的答案很簡單:不,這是不可能的,原因很簡單,rotate包中的命令按設計旋轉其範圍內的所有內容。

但你不需要額外的包包。環境tikzpicture有選項rotate,它將旋轉除標籤之外的所有內容。

在此輸入影像描述

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[scale=1,rotate=0]
\draw [->] (3.5, 1.5)-- (4.25, 3.75); 
\node at (4.45, 3.75) {$u$}; 
\end{tikzpicture}
\begin{tikzpicture}[scale=1,rotate=-37]
\draw [->] (3.5, 1.5)-- (4.25, 3.75); 
\node at (4.45, 3.75) {$u$}; 
\end{tikzpicture}
\begin{tikzpicture}[scale=1,rotate=30]
\draw [->] (3.5, 1.5)-- (4.25, 3.75); 
\node at (4.45, 3.75) {$u$}; 
\end{tikzpicture}
\end{document} 

相關內容