1

I have the following image:enter image description here Produced from the following LaTeX code:

\begin{figure}[h!]
        \centering
        \begin{subfigure}[b]{0.6\textwidth}
      \includegraphics[width=0.7\textwidth, trim=5cm 5cm 5cm 5cm]{images/det.pdf}
    \caption{Deterministic algorithms}
  \label{fig:fingonly1}
        \end{subfigure}%
        ~ %add desired spacing between images, e. g. ~, \quad, \qquad etc.
          %(or a blank line to force the subfigure onto a new line)
        \begin{subfigure}[b]{0.6\textwidth}
      \includegraphics[width=0.7\textwidth, trim=5cm 5cm 5cm 5cm]{images/pro.pdf}
  \caption{Probabilistic algorithms}
  \label{fig:fingonly2}
        \end{subfigure}
        \caption{Average positioning error for the non-dynamic indoor positioning system}\label{fig:rssi}
\end{figure}

I want to center the text with the image. any recommendations on how to fix this?

5
  • Are you producing the images using pgfplots? if so, you could pass trim axis options to tikzpicture, as in \begin{tikzpicture}[trim axis left,trim axis right]...\end{tikzpicture}. Commented Apr 8, 2014 at 23:38
  • I am using \usepackage{graphicx}, not pgfplots, any recommendations on how to fix it with graphicx Commented Apr 8, 2014 at 23:40
  • I meant to produce the plot bars, not to include them. Or are they just -pdf files you already have? Commented Apr 8, 2014 at 23:41
  • I made them on excel and then I export them as PDF, I use trim to remove the white space created from excel in the chart. Commented Apr 8, 2014 at 23:42

1 Answer 1

0

The problem is that your images are not centered inside the subfigure environments and that the total length for both images will be greater than \textwidth.

I used \centering inside each subfigure environment; I also reduced the subfigure width to half \textwidth and removed extra spaces between them:

\documentclass{article}
\usepackage{graphicx}
\usepackage{subcaption}

\begin{document}

\begin{figure}
\begin{subfigure}[b]{0.5\textwidth}
  \centering
  \includegraphics[width=0.7\textwidth, trim=5cm 5cm 5cm 5cm]{1det}
  \caption{Deterministic algorithms}
  \label{fig:fingonly1}
\end{subfigure}%
\begin{subfigure}[b]{0.5\textwidth}
  \centering
  \includegraphics[width=0.7\textwidth, trim=5cm 5cm 5cm 5cm]{1prob}
  \caption{Probabilistic algorithms}
  \label{fig:fingonly2}
\end{subfigure}
\caption{Average positioning error for the non-dynamic indoor positioning system}
\label{fig:rssi}
\end{figure}

\end{document}

enter image description here

Try not to use [!h] as placement specifier; either use a not so restrictive option or, even better, not use any at all.

0

You must log in to answer this question.

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