matlab2tikz escala el ancho variable por factor 0.95092

matlab2tikz escala el ancho variable por factor 0.95092

Utilizo variables globales predeterminadas \figwidthpara el ancho y \figheightel alto de la figura en mi documento.

Estos están definidos por el siguiente código en el encabezado de mi 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

En Matlab, paso las variables antes mencionadas a matlab2tikz.m como se muestra a continuación:

matlab

x = linspace(0,5,500);
y = sin(x);

figure
plot(x,y)
title('Sine Plot')

cleanfigure;
matlab2tikz('width','\figwidth','height','\figheight');

Sin embargo, parece estar sucediendo algo de magia dentro de matlab2tikz, ya que aplica elfactor 0,95092a mi 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}%

Mi solución actual es agregar un 0 en el código de Matlab:

matlab

matlab2tikz('width','0\figwidth','height','\figheight');

cuyos rendimientos:

Látex

width=0\figwidth,

es decir, el resultado final al considerar mi definición inicial de \figwidthlecturas.

width=00.8\textwidth,   % = 0\figwidth

lo cual está bien por ahora, pero podría romper el código en algunas situaciones que no involucran un factor en mi definición inicial de la variable de ancho. Por ejemplo

\newcommand{\figwidth}{\textwidth}

produciría un ancho de figura cero:

width=0\textwidth,   % = 0\figwidth = 0

Busqué este factor en todos los archivos *.m contenidos en la carpeta src del paquete matlab2tikz, pero no encontré resultados en el código.

tl: dr;¿Alguien sabe qué está causando el factor mágico 0,95092 y cómo evitarlo? ¡De antemano muchas gracias por tu ayuda!

Respuesta1

publicación idénticaen Githubfue respondido. Consulte el enlace de Github para obtener respuesta.

información relacionada