\figwidth
내 문서에서는 그림 너비와 \figheight
높이에 전역 기본 변수를 사용합니다 .
이는 내 문서 헤더의 다음 코드로 정의됩니다.
유액
\newcommand{\figwidth}{0.8\textwidth} % sets \figwidth, which can be used as default width for figures
\newcommand{\figheight}{\figwidth/1.618} % sets \figheight, which can be used as default heigth for figures
Matlab에서는 아래와 같이 앞서 언급한 변수를 matlab2tikz.m에 전달합니다.
매트랩
x = linspace(0,5,500);
y = sin(x);
figure
plot(x,y)
title('Sine Plot')
cleanfigure;
matlab2tikz('width','\figwidth','height','\figheight');
그러나 matlab2tikz 내부에는 마법 같은 일이 일어나는 것 같습니다.계수 0.95092내가 미리 정의한\figwidth
유액
\begin{tikzpicture}
\begin{axis}[%
width=0.95092\figwidth,
height=\figheight,
at={(0\figwidth,0\figheight)},
scale only axis,
separate axis lines,
every outer x axis line/.append style={black},
every x tick label/.append style={font=\color{black}},
xmin=0,
xmax=5,
every outer y axis line/.append style={black},
every y tick label/.append style={font=\color{black}},
ymin=-1,
ymax=1,
title={Sine Plot}
]
\addplot [color=blue,solid,forget plot]
table[row sep=crcr]{%
0 0\\
0.0100200400801603 0.010019872410322\\
0.0200400801603206 0.020038738821815\\
0.030060120240481 0.0300555933366527\\
//..... many more entries in table .....
4.98997995991984 -0.961718395396395\\
5 -0.958924274663138\\
};
\end{axis}
\end{tikzpicture}%
현재 해결 방법은 Matlab 코드에 0을 추가하는 것입니다.
매트랩
matlab2tikz('width','0\figwidth','height','\figheight');
결과는 다음과 같습니다.
유액
width=0\figwidth,
\figwidth
즉, 읽기 에 대한 초기 정의를 고려할 때 최종 결과입니다.
width=00.8\textwidth, % = 0\figwidth
지금은 괜찮지만 너비 변수의 초기 정의에 포함되지 않은 일부 상황에서는 코드가 손상될 수 있습니다. 예를 들어
\newcommand{\figwidth}{\textwidth}
그림 너비가 0이 됩니다.
width=0\textwidth, % = 0\figwidth = 0
이 요소에 대해 matlab2tikz 패키지의 src 폴더에 포함된 모든 *.m 파일을 검색했지만 코드에서 결과를 찾지 못했습니다.
tl:dr;매직 팩터 0.95092의 원인과 이를 방지하는 방법을 아는 사람이 있습니까? 도움을 주셔서 미리 감사드립니다!
답변1
동일한 게시물Github에서대답했다. 답변은 Github 링크를 참조하세요.