# Four figures in two column page

Referring to this link, Placement of images in row using subfigure

when I use the same code of the tabular format for my two-column page format, it cross the first column width. I have already used \columnwidth to fit it within single column, but it doesn't work.

\begin{figure}
\centering
\begin{tabular}[c]{cccc}
\begin{subfigure}[b]{0.24\columnwidth}
\includegraphics[width=\textwidth]{figure/E_field_513_THz_X_normal.eps}
\caption{E field at 513 THz x-normal direction.}
\end{subfigure}&
\begin{subfigure}[b]{0.24\columnwidth}
\includegraphics[width=\textwidth]{figure/E_field_513_THz_Y_normal.eps}
\caption{E field at 513 THz in y-normal direction.}
\end{subfigure}&
\begin{subfigure}[b]{0.24\columnwidth}
\includegraphics[width=\textwidth]{figure/H_field_513_THz_Y_normal.eps}
\caption{H field at 513 THz y-normal direction.}
\end{subfigure}&
\begin{subfigure}[b]{0.24\columnwidth}
\includegraphics[width=\textwidth]{figure/H_field_513_THz_X_normal.eps}
\caption{H field at 513 THz x-normal direction.}
\end{subfigure}
\end{tabular}
\caption{The electric and magnetic fields pattern at 513 THz.}
\label{E_and_H_field_at_513}
\end{figure}


Can someone help?

• Hi, I am new user, I am not sure what exactly you mean. Do you mean I should add this line before the code, so that one can compile this online without any package. \documentclass[9pt,twocolumn,twoside]{osajnl} – vishal Nov 24 '18 at 21:46
• Does it almost work? Tabular adds a 2\tabcolsep space between columns, which may be more than 0.1\columnwidth. You don't need a tabular here. Just place \hfil or \hfill between the subfigures and they will space out nicely. – John Kormylo Nov 25 '18 at 16:54
• your question isn't very clear, but \begin{subfigure}[b]{0.24\columnwidth} \includegraphics[width=\textwidth]{f specifies that the subfigure is less that a quarter of the column, so less than an eighth of the text width, and yet it has to contain an image that is scaled to the full text width, that is not going to fit. – David Carlisle Nov 27 '18 at 23:23
• Hi, According to the link (included in my post), tabular help to make better placement of figure as well as the caption. If I remove the tabular, the placement of caption almost overlaps with each other and it looks very bad. – vishal Nov 29 '18 at 9:09
• Hi an online template available from overleaf webpage. I don't know how to share everything. Here is the link. overleaf.com/latex/templates/… – vishal Nov 30 '18 at 19:13

pretty late ...

\documentclass[9pt,twocolumn,twoside]{article}% {osajnl} sorry i can't find this document class
%\journal{ol}  % Choose journal (ao, aop, josaa, josab, ol, pr)
\usepackage[demo]{graphicx}
\usepackage{caption}
\usepackage{subcaption}
\captionsetup[subfigure]{font=footnotesize,
justification= raggedright}

\usepackage{lipsum}
\begin{document}
\lipsum[1]
\begin{figure}[htb]
\setkeys{Gin}{width=\linewidth}
\begin{subfigure}[b]{0.23\columnwidth}
\includegraphics{figure/E_field_455_THz_X_normal.eps}
\caption{E field at 455THz in x-normal direction.}
\label{fig:bear}%?
\end{subfigure}\hfill
\begin{subfigure}[b]{0.23\columnwidth}
\includegraphics{figure/E_field_455_THz_Y_normal.eps}
\caption{E field at 455THz in y-normal direction.}
\label{fig:lion}%?
\end{subfigure}\hfill
\begin{subfigure}[b]{0.23\columnwidth}
\includegraphics{figure/H_field_455_THz_X_normal.eps}
\caption{H field at 455THz x-normal direction.}
\label{fig:tiger}
\end{subfigure}\hfill%
\begin{subfigure}[b]{0.23\columnwidth}
\includegraphics{figure/H_field_455_THz_Y_normal.eps}
\caption{H field at 455THz y-normal direction.}
\label{fig:mouse}
\end{subfigure}
\caption{Same figure as previous figure in single row}
\label{figure_in_line}
\end{figure}

\lipsum[2]
\end{document}


I used the following code, it solves the problem but still has an issue with the caption of each figure. The figure caption almost overlaps with each other.

\documentclass[9pt,twocolumn,twoside]{osajnl}
\journal{ol}  % Choose journal (ao, aop, josaa, josab, ol, pr)

\begin{document}

\begin{figure}
\begin{subfigure}[b]{0.24\columnwidth}
\centering                \includegraphics[width=.95\linewidth]{figure/E_field_455_THz_X_normal.eps}
\caption{E field at 455THz in x-normal direction.}
\end{subfigure}%
\begin{subfigure}[b]{0.24\columnwidth}
\centering
\includegraphics[width=.95\linewidth]{figure/E_field_455_THz_Y_normal.eps}
\caption{E field at 455THz in y-normal direction.}
\end{subfigure}%
\begin{subfigure}[b]{0.24\columnwidth}
\centering
\includegraphics[width=.95\linewidth]{figure/H_field_455_THz_X_normal.eps}
\caption{H field at 455THz x-normal direction.}
\label{fig:tiger}
\end{subfigure}%
\begin{subfigure}[b]{0.24\columnwidth}
\centering
\includegraphics[width=.95\linewidth]{figure/H_field_455_THz_Y_normal.eps}
\caption{H field at 455THz y-normal direction.}
\label{fig:mouse}
\end{subfigure}
\caption{Same figure as previous figure in single row}
\label{figure_in_line}
\end{figure}

\end{document}