
この tex ファイルは matlab から取得されています。
\begin{tikzpicture}
\begin{axis}[%
width=\figurewidth,
height=\figureheight,
scale only axis,
xmin=1,
xmax=5,
ymin=2,
ymax=10
]
\addplot [color=red,line width=4.0pt,only marks,mark=*,mark options={solid},forget plot]
table[row sep=crcr]{
1 2 \\
2 4 \\
3 6 \\
4 8 \\
5 10 \\
};
\end{axis}
\end{tikzpicture}%
追加したいのですxlabel
が、ylabel
その中に
xmin=1,
xmax=5,
ymin=2,
ymax=10,
xlabel=X,
ylabel=Y,
前述のように別のLaTeXファイルを実行するとここ。
\documentclass{minimal}
\newwrite\tempfile
\begin{document}
\immediate\openout\tempfile=lists.tex
\immediate\write\tempfile{xlabel=X,}
\immediate\write\tempfile{ylabel=Y,}
\immediate\closeout\tempfile
\input{lists}
\end{document}
これらを特定の行に書き込むことはできますか?
答え1
キーxlabel
とylabel
設定も可能外tikzpicture
matlab から、\pgfplotsset
例:
\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\newdimen\figurewidth
\newdimen\figureheight
\begin{document}
\begingroup
\pgfplotsset{xlabel=$X$, ylabel=$Y$}
\setlength{\figurewidth}{5cm}
\setlength{\figureheight}{5cm}
% Matlab export
\begin{tikzpicture}
\begin{axis}[%
width=\figurewidth,
height=\figureheight,
scale only axis,
xmin=1,
xmax=5,
ymin=2,
ymax=10
]
\addplot [color=red,line width=4.0pt,only marks,mark=*,mark
options={solid},forget plot]
table[row sep=crcr]{
1 2 \\
2 4 \\
3 6 \\
4 8 \\
5 10 \\
};
\end{axis}
\end{tikzpicture}%
\endgroup
\end{document}
答え2
emacs replace-regexp 関数のみを使用するソリューション:
M-x replace-regexp RET \(ymax=[0-9]+\) RET \1, C-q C-j xlabel=X, C-q C-j ylabel=Y