ドキュメント内の\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}
図の幅はゼロになります:
width=0\textwidth, % = 0\figwidth = 0
この要因について、matlab2tikz パッケージの src フォルダーに含まれるすべての *.m ファイルを検索しましたが、コード内に結果は見つかりませんでした。
要約:マジックファクター 0.95092 の原因と回避方法を知っている人はいますか? ご協力ありがとうございます!
答え1
同一の投稿Githubで回答がありました。返信については Github リンクを参照してください。