여러 축 설정을 재사용하기 위해 사용자 정의 축 속성을 정의하는 방법은 무엇입니까?

여러 축 설정을 재사용하기 위해 사용자 정의 축 속성을 정의하는 방법은 무엇입니까?

편집: 이 게시물의 원래 이름은 "siunitx가 newcommand 내부에 \endcsname을 던지는 이유는 무엇입니까?"이지만 이름 변경이 질문의 의도를 더 잘 반영한다고 생각합니다.

이 코드(siunitx 명령으로 추적됨 \unit)가 \endcsname? newcommand의 일반적인 함정은 무엇입니까?

\documentclass{article}
\usepackage{pgfplots}
\usepackage{siunitx}
\pgfplotsset{compat=1.18}

\begin{document}
    \newcommand{\axissettings}{ymin=-1, xlabel={Test with $\unit{\celsius}$}}
    
    \begin{figure}
        \begin{tikzpicture}
            \begin{axis}[grid, \axissettings]
                \addplot coordinates {(0,0)};
            \end{axis}
        \end{tikzpicture}
    \end{figure}
\end{document}

감사합니다

답변1

나는 이것이 그다지 번거롭지 않다고 생각합니다. 연결된 답변의 나머지 부분에서 쫓겨 났습니까?

\documentclass{article}
\usepackage{pgfplots}
\usepackage{siunitx}
\pgfplotsset{compat=1.18}
\pgfplotsset{yourcustomaxissettings/.style={ymin=-1, xlabel={Test with $\unit{\celsius}$}}}

\begin{document}
    
    \begin{figure}
        \begin{tikzpicture}
            \begin{axis}[grid,yourcustomaxissettings,ymax=1,xmin=-1,xmax=1]
                \addplot coordinates {(0,0)};
            \end{axis}
        \end{tikzpicture}
    \end{figure}
\end{document}

관련 정보