1

I have a document with two columns, I want to insert a figure that is as wide as the entire page (not only in one column).

my figure is a matlab graphic in .eps format. I use \usepackage{multicol} {2} for the columns. I have inserted my figure using

\begin{figure}[H]
\includegraphics[width=18cm]{figures/subplotting3.eps}
\caption{text}
\label{fig:text}
\end{figure}

so far so good, however the figure is not 18cm wide (18cm = page without borders) and the font of the axis of the figure shrinks! I have set the font style to 10pt in matlab

I need to understand how to import such figures from matlab without getting smaller fonts and having it on the same wide as the page. I guess the method of setting the width of the figure to 18cm manually is not the correct way to do it. Do I need some additional packages? enter image description here

1
  • try to use figure* ! For further help, please extend your code fragment to complete small document, which we can compile as it is.
    – Zarko
    Oct 19, 2020 at 11:29

1 Answer 1

2

Please include the complete LaTeX code next time, with the class and packages you use, to help produce a response that meets your requirements. Here I just use the code from your former question.

Your snippet works, but the wide figure will be set on the next page.

A smaller figure, with a less than a column width will do fine.

Try this code.

\documentclass[10pt, a4paper,twoside]{scrartcl}

\usepackage{kantlipsum} %dummy text

\usepackage{graphicx}
\usepackage{multicol} 
\usepackage{float}

\usepackage{fancyhdr} % from previuos question
\pagestyle{fancy}

\fancypagestyle{plain}{}
\fancyhf{}

\fancyhead[RE,LO]{\rmfamily \small \nouppercase \leftmark}

\setlength{\headsep}{.5cm}

\begin{document}
    
\begin{multicols}{2}
    \section*{Abstract \protect\markboth{Abstract}{Abstract} }
    \kant[1]
    \newpage    
    \section{Introduction}      
    \kant[2]

    \begin{figure}[H]
        \centering
        \includegraphics[width=100pt]{example-grid-100x100pt}
        \caption{text}
        \label{fig:text}
    \end{figure}

    \kant[12-13]
    \newpage  
    \section{Basics}
    \kant[4-6]  
\end{multicols} 


\begin{figure*}
\includegraphics[width=\textwidth]{example-image-A}
\caption{text}
\label{fig:text}
\end{figure*}

    \begin{multicols}{2}
        \kant[7-9]
        \newpage
        \section*{Appendix \protect\markboth{Appendix}{Appendix}}
    \end{multicols}

\end{document}

Notice that the multicols environment was interrupted to allow the insertion of the figure at a particular place.

To correct the fonts of an exported MATLAB figure, you should try

1. Change the MATLAB figure configuration settings until you get the correct combinations of image width, font and fontsize that will look good in your LateX document. (If possible use the same sf font of the main document).

I haven't used MATLAB for a long time so I can't help here.

2. Use an .eps (vector) editor such as Inkscape to add or correct the axis labels and other references. It is very good software and it is free. Recommended!!

I found this old recipe in my archive. Probably from an older forum. I guess there are much better tools now.

Create the graph of a MATLAB figure and inspect it on the screen, until is exactly the way you want it to appear in your document. Save the figure as .pdf or .png using export_fig at full resolution (600 dpi). export_fig will respect the dimensions of the figure and embed fonts, producing high-quality bitmaps.

Take a look at the File Exchange

https://www.mathworks.com/matlabcentral/fileexchange?q=export+to+figure++latex

wide

small

UPDATE

To put the figure on the same page after the text in two columns:

1 The text must be shorter, that is, the two columns must end in a suitable place to leave enough space for the figure.

2 Then, issue a \clearpage after the environment in the figure to flush the floats.

3 LaTeX will place the floats on the top of the page. (SOP)

See the updated answer.

To put the figure exactly where you want, against all LaTeX wishes, with your setup, well ... I think it deserves another question!

There are many possible solutions. Search the topic in this forum.

\documentclass[10pt, a4paper,twoside]{scrartcl}

\usepackage{kantlipsum} %dummy text

\usepackage{graphicx}
\usepackage{multicol} 

\usepackage{float}      

\usepackage{fancyhdr} % from previuos question
\pagestyle{fancy}

\fancypagestyle{plain}{}
\fancyhf{}

\fancyhead[RE,LO]{\rmfamily \small \nouppercase \leftmark}

\setlength{\headsep}{.5cm}

\begin{document}
    
\begin{multicols}{2}
    \section*{Abstract \protect\markboth{Abstract}{Abstract} }
    \kant[1]
    \newpage    
    \section{Introduction}      
    \kant[2]

    \begin{figure}[H]
        \centering
        \includegraphics[width=100pt]{example-grid-100x100pt}
        \caption{text}
        \label{fig:text}
    \end{figure}    

    \kant[12-13]
    \newpage  
    \section{Basics}
    \kant[4]    
\end{multicols}     
\begin{figure*}
\includegraphics[width=\textwidth]{example-image-A}
\caption{text}
\label{fig:texti}
\end{figure*}
\clearpage

    \begin{multicols}{2}        
        \kant[7-9]
        \newpage
        \section*{Appendix \protect\markboth{Appendix}{Appendix}}
    \end{multicols}

\end{document}

floater

Using the caption package and without using the figure environment

\begin{center}
    \includegraphics[width=\textwidth]{example-image-A} 
    \label{fig:texti}
    \captionof{figure}{text}
\end{center}

you will get

no float

2
  • thank you very much for this clear answer. Just one more thing, what do I do if I want to have first the text in two columns and on the same page (after the text) my figure over both columns. Same as your screenshot with the figure A just vis-a-versa Oct 19, 2020 at 13:07
  • @caarloXY See my updated answer. Oct 19, 2020 at 17:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .