当前代码如下所示,打印出带有风向(以度为单位)的图形标题。我正在寻找一种方法来保留 for 循环并将标题中的风向更改为文本,例如 N、S、E、W、SW、SE 等。
\foreach \wind in {135,157,180,202,225,236,247,258} {%
\begin{figure}[H]
\centering
\includegraphics[width=1\linewidth]{Wind_report_of\wind_direction.png}
\caption{Wind Direction: \wind°}\label{Design\wind}
\end{figure}
}
答案1
答案2
\documentclass{article}
\usepackage{pgffor}
\begin{document}
\ExpandArgs{c}\newcommand{wind135}{A}
\ExpandArgs{c}\newcommand{wind157}{N}
\ExpandArgs{c}\newcommand{wind180}{S}
\ExpandArgs{c}\newcommand{wind202}{NW}
\ExpandArgs{c}\newcommand{wind225}{B}
\ExpandArgs{c}\newcommand{wind236}{E}
\ExpandArgs{c}\newcommand{wind247}{SW}
\ExpandArgs{c}\newcommand{wind258}{W}
\foreach \wind in {135,157,180,202,225,236,247,258} {%
\wind\ is \UseName{wind\wind}
}
\end{document}