EDIT: This might be solved with just the knowledge of what size \textwidth in points or centimeters is with this setup.
I have the problem of exporting MATLAB figures to LaTeX and keeping the font size of the axis labels. I want to achieve the right export size to have two figures side-by-side reaching the whole textwidth. (See the figure which have too small axis font size)
As I don't export my figures with the right width in MATLAB, LaTeX will scale the picture and the axis labels will change in size. MATLAB's export setup allows me to export exact size of the figure in points or centimeters with the right font size of the axis labels.
What width should I use when exporting from MATLAB and how should I implement the code in LaTeX to fulfill this?
\documentclass[12pt, a4paper]{article}
\usepackage[english]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[font={small,it}]{caption}
\usepackage{subcaption}
\usepackage{graphicx}
\begin{document}
\begin{figure}
\centering
\begin{subfigure}{0.45\textwidth}
\centering
\includegraphics[width = \textwidth]{B1_coarse.png}
\caption{Coarse mesh with \(h_{max} = 1/2\).}
\label{fig:b1_coarse}
\end{subfigure}
~
\begin{subfigure}{0.45\textwidth}
\includegraphics[width = \textwidth]{B1_fine.png}
\caption{Fine mesh with \(h_{max} = 1/32\).}
\label{fig:b1_fine}
\centering
\end{subfigure}
\end{figure}
\end{document}




set(gca,'FontSize',16), for instance. You can also export the figure tosvg(although it might get large for this kind of picture) and export it to LaTeX withinkscape. Finally, you can make the picture directly in LaTeX withpgfplots. – Phelype Oleinik Dec 12 '18 at 14:34\textwidthvaries with your document setup, but you can find out very easily. Just type\the\textwidthsomewhere in the text and TeX will print the value of\textwidthinpt:) P.S.: In the occasion of your edit, then your question is a duplicate of this one – Phelype Oleinik Dec 12 '18 at 14:49h_{\mathrm{max}}(never use math italic for multi-letter words) also would be better to use\end{subfigure}\hfill\begin{subfigure}rather than\end{subfigure} ~ \begin{subfigure}currently you have .1\textwidth to fill (as your subfigures add up to .9) but you put three word spaces between, which might not be able to shrink enough (forcing the second figure in to the margin) or might not be able to stretch enough (leaving a gap to the right of the second figure) – David Carlisle Dec 12 '18 at 15:21