Eu uso variáveis padrão globais \figwidth
para largura e \figheight
altura da figura em meu documento.
Eles são definidos pelo seguinte código no cabeçalho do meu documento:
Látex
\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
No Matlab, passo as variáveis mencionadas para matlab2tikz.m conforme mostrado abaixo:
Matlab
x = linspace(0,5,500);
y = sin(x);
figure
plot(x,y)
title('Sine Plot')
cleanfigure;
matlab2tikz('width','\figwidth','height','\figheight');
No entanto, parece haver alguma mágica acontecendo dentro do matlab2tikz, pois ele aplica ofator 0,95092para o meu predefinido\figwidth
Látex
\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}%
Minha solução atual é adicionar um 0 no código Matlab:
Matlab
matlab2tikz('width','0\figwidth','height','\figheight');
que produz:
Látex
width=0\figwidth,
ou seja, o resultado final ao considerar minha definição inicial de \figwidth
leituras
width=00.8\textwidth, % = 0\figwidth
o que é bom por enquanto, mas pode quebrar o código em algumas situações que não envolvem um fator na minha definição inicial da variável width. Por exemplo
\newcommand{\figwidth}{\textwidth}
renderia largura de figura zero:
width=0\textwidth, % = 0\figwidth = 0
Pesquisei todos os arquivos *.m contidos na pasta src do pacote matlab2tikz em busca desse fator, mas não encontrei resultados no código.
tl: dr;Alguém sabe o que está causando o fator mágico 0,95092 e como evitá-lo? Muito obrigado antecipadamente por sua ajuda!
Responder1
postagem idênticano Githubfoi respondido. Veja o link do Github para resposta.