1

I have written the following code to arrange three figures as you see in the picture below. Do you have any idea, how can I better arrange these figures? for some reasons there are lots of free space in the right and left of the pictures. If I replace 0.45\textwidth by, for example, 0.5\textwidth, then I will have three figures aligned in column!! BTW, I cannot use \subfigure command due to the clash between the packages. enter image description here Many thanks

\documentclass[letterpaper,12pt,oneside,final]{book}

\usepackage{tikz,float,subfig}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{pgfplots}
\usepackage{mwe}
\newsavebox{\measurebox}

\begin{document}
%%%%%
%%%%%
\begin{figure}
\centering
\sbox{\measurebox}{%
  \begin{minipage}[b]{0.45\textwidth}
  \subfloat[]
    {
    \begin{tikzpicture}[baseline]
\begin{axis}[
  width=\textwidth,
]
\addplot[solid,smooth,mark=none,color={rgb,255:red,0; green,0; blue,255}]
coordinates {(9.8,0) (10.1,0.25)
         (10.4,0.5) (10.7,0.75) (11,1)};
\end{axis}
\end{tikzpicture}
    }
  \end{minipage}}
\usebox{\measurebox}
\begin{minipage}[b][\ht\measurebox][s]{0.45\columnwidth}
\centering
\subfloat[]
  {
  \begin{tikzpicture}[baseline]
   \begin{axis}[
   width=0.5\textwidth,
   ]
\addplot[solid,smooth,mark=none,color={rgb,255:red,0; green,0; blue,255}]
coordinates {(-180,0) (-90,0.25)
         (0,0.5) (90,0.75) (180,1)};
\end{axis}
\end{tikzpicture}
  \label{fig:Ex02_FT_fields}
  }

\vfill

\subfloat[]
  {\includegraphics[width=0.5\textwidth,height=2cm]{{example-image-a}}\label{fig:figC}}
\end{minipage}
\caption{my caption. (a) is .... (b) is .... (c) is ....}
\label{fig:Test}
\end{figure}
\end{document} 
  • welcome to tex.se! please extend your code snippet to complete small document (beginning with \documentclass, ending with \end{document} and containing all data that code of figures can be compiled) with your figure. from your code fragment we can't reproduce your problem. – Zarko Mar 26 at 23:04
  • @Zarko yes, I edited my code. – Yousef Vh Mar 27 at 2:50
  • unfortunately your mwe (minimal working example) doesn't work. it also is not minimal. please remove from preamble all packages and your definitions not needed for showing your mages. – Zarko Mar 27 at 2:56
  • I modified it again and made the code minimal. Tested in a different directory on my computer and It works now. – Yousef Vh Mar 27 at 3:28
  • meanwhile i already wrote my answer :-), where i made own minimal version of your code. see if it help you. – Zarko Mar 27 at 3:43
1

i guess that you like to obtain something like this:

enter image description here

above result i obtain by the following MWE (Minimal Working Example):

\documentclass[letterpaper,12pt,oneside,final]{book}
\usepackage[demo]{graphicx}
\usepackage{caption}
\usepackage{subfig}

\usepackage{amsmath}
\usepackage{pgfplots}
\pgfplotsset{compat = newest}

\usepackage{lipsum} % for dummy text

\begin{document}
\lipsum[1]
    \begin{figure}[htb]
  \begin{minipage}[b]{0.60\textwidth}
  \subfloat[]
    {
    \begin{tikzpicture}
\begin{axis}[
  width=\linewidth,
  line width=1pt,
  ymin=0, ymax=1,
  xmin=9.8, xmax=11,
  xlabel=Frquency (GHz),
  ylabel=$\left|S_{64}\right|$,
            ]
\addplot[mark=none] coordinates {(9.8,0) (10.1,0.25)
                                 (10.4,0.5) (10.7,0.75) (11,1)};
\end{axis}
\end{tikzpicture}
    }
  \end{minipage}\hfill%
\begin{minipage}[b]{0.35\columnwidth}
    \centering
\subfloat[]
  {
  \begin{tikzpicture}
   \begin{axis}[
   width=\linewidth,
   line width=1pt,
   ymin=0, ymax=1,
   xmin=-180, xmax=180,
   xlabel=$\theta\,\left(\text{degree}\right)$,
   ylabel=$\text{FT}\left( H_z\right)$,
   ]
\addplot[mark=none] coordinates {(-180,0) (-90,0.25)
                                 (0,0.5) (90,0.75) (180,1)};
\end{axis}
\end{tikzpicture}
    \label{fig:Ex02_FT_fields}
  }

\subfloat[]
  {
\includegraphics[width=\linewidth,height=2cm,keepaspectratio]{figures/temp_disp}
    \label{fig:figC}
  }
\end{minipage}
    \caption{my caption. (a) is .... (b) is .... (c) is ....}
    \label{fig:Test}
    \end{figure}
\lipsum[2]
\end{document}

as you can see, i remove all packages and your definitions, which are not relevant to your problem. i must confess that i not understand your way to including image in figure. it seems that use of savingbox is source of your problem. remove them and correct definition of width of images form width=\textwidth to \linewidth can do job better.

I also not figure out proportion of width of mini pages. you can change as you wish.

  • Yes, this works now — many thanks. The reason I didn't initially remove the packages and definitions in the preamble was to let people know what I have there, which is part of a very big document. And also to let them know that I cannot remove them!!:)), as other parts of my document may give an error. Anyways, now your code works. And you are right, the problem was savingbox – Yousef Vh Mar 27 at 4:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.