I'm quite new at latex, but finding it awesome. Yet when it comes to figures things do get a bit tiresome.
I'm currently linking a big amount of matlab plots with latex articles with matlab2tikz
. After downsampling the figures quite a lot, it finally got correctly linked.
But the thing is that now I need to control the display properties of the figures in the document WITHOUT changing stuff in the document of the picture itself.
The way I include the plot in latex is:
\input{/path/fig.tex}
\FloatBarrier
But I can't control very well scale, centering and so on.. tried with construction like:
\begin{figure}[scale=0.5]
\center
\input{/path/fig.tex}
\end{figure}
or the same with a {tikzpicture}
…
Maybe setting this kind of parameters in the matlab2tikz
command itself, in the Matlab script.
Well, any help is appreciated..
Best Answer
With regard to scaling plots, there are a few options. Is there anything else you want to do?
Option 1 - Setting width and height
When using
matlab2tikz
you can specify the width and height of figures:Note that, if I remember correctly, this will set the size of just the axis. Hence, the total width will be 8cm + the width of yticks, ylabel, and other stuff next to the axis itself.
This won't help you with scaling the plots on the LaTeX end of course, but what you can do instead is to set the width to macros that you define in your LaTeX document. For example, you can say
in Matlab, and have a LaTeX file such as
Option 2 - Adding a scale parameter
You also have the option to specify additional options for the
tikzpicture
andaxis
environments generated bymatlab2tikz
. This way you can set ascale
parameter for one of them, and have a macro holding the value. In Matlab, doand have a LaTeX file as
Adding the
scale
parameter to theaxis
will not change the size of tick labels and axis labels. If you use'extraTikzpictureOptions','scale=\figurescale
in the call tomatlab2tikz
, instead of'extraAxisOptions'
, scaling will change the size of axis labels etc.Option 3 - the
tikzscale
package(I totally forgot to add this option, which is actually quite convenient. SOrry about that.)
The
tikzscale
package modifies the\includegraphics
command so that it can be used instead of\input
for.tikz
files, and the same scaling options can be used.Note that you must use
.tikz
as the file ending,.tex
is not recognized.A quick code example:
Lastly a note about your second code snippet:
There are two things that are wrong here.
figure
environment is just a floating container in which you can put stuff, such as images. It has no options for scaling or similar, so[scale=0.5]
does nothing here.\centering
, not\center
. There is also acenter
environment, used as\begin{center} ... \end{center}
, but within figures it is recommended to use\centering
(see Should I use center or centering for figures and tables?).