Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have three images that i need to show on the same horizontal level. THe problem that iam having is that the image description that i place below is overflowing on to the second line. Moreover there is a huge space between the image identifier character and the beginning of the word.(between a) and EN-)

Here is my code

\begin{figure}[!h]  
  \centering  
  \subfloat[ENGINE1]{\label{fig:gull}\includegraphics[width=0.1\textwidth]{textures_data_types/lzw.eps}}     
   \hspace{2px}
 \subfloat[ENGINE12]{\label{fig:gull}\includegraphics[width=0.1\textwidth]{textures_data_types/wav.eps}}     
    \hspace{2px}
 \subfloat[BITMAP]{\label{fig:gull}\includegraphics[width=0.1\textwidth]{textures_data_types/bit.eps}}  
 \caption{Systems} 
     \label{fig:bitmapVisualize}
\end{figure}

enter image description here

share|improve this question
    
The subfig package may help you. Also, read section 1.1 "Do You Need This Package?" from the package's documentation. There are three examples that may be exactly what you need. –  Gustavo Aug 4 '12 at 16:45
    
if i hadn't imported the subfig package i wouldn't have had this issue in the first place –  user581544 Aug 4 '12 at 16:57
    
Sorry, I thought you were using subfigure or something else. –  Gustavo Aug 4 '12 at 17:10

2 Answers 2

up vote 2 down vote accepted

The width of the \subfloat is determined by the graphic. Therefore, place the graphic inside a box of fixed width larger than the original graphic. Something like the following:

\begin{figure}[!h]  
  \centering  
  \subfloat[ENGINE1]{\label{fig:gull}\makebox[7em]
    {\includegraphics[width=0.1\textwidth]{textures_data_types/lzw.eps}}}
  \quad
  \subfloat[ENGINE12]{\label{fig:gull}\makebox[7em]
   {\includegraphics[width=0.1\textwidth]{textures_data_types/wav.eps}}}
  \quad
  \subfloat[BITMAP]{\label{fig:gull}\makebox[7em]
    {\includegraphics[width=0.1\textwidth]{textures_data_types/bit.eps}}}
  \caption{Systems} 
  \label{fig:bitmapVisualize}
\end{figure}

The above places all images in a box of width 7em, centred (by default). Modify the length to suit.


In twocolumn document mode, you should rather use \columnwidth as your width specifications:

enter image description here

\documentclass[twocolumn]{article}
\usepackage{lipsum}% http://ctan.org/pkg/lipsum
\usepackage[demo]{graphicx}% http://ctan.org/pkg/graphicx
\usepackage{subfig}% http://ctan.org/pkg/subfig

\begin{document}
\lipsum[1]
\begin{figure}
  \centering  
  \subfloat[ENGINE1]{\label{fig:engine1}\makebox[.3\columnwidth]
    {\includegraphics[width=0.3\columnwidth]{textures_data_types/lzw.eps}}}
  \quad
  \subfloat[ENGINE12]{\label{fig:engine12}\makebox[.3\columnwidth]
    {\includegraphics[width=.3\columnwidth]{textures_data_types/wav.eps}}}
  \quad
  \subfloat[BITMAP]{\label{fig:bitmap}\makebox[.3\columnwidth]
    {\includegraphics[width=0.3\columnwidth]{textures_data_types/bit.eps}}}
  \caption{Systems} 
  \label{fig:bitmapVisualize}
\end{figure}
\end{document}

If need be, you can reduce the \subfloat font size by issuing something like \footnotesize inside it (\subfloat[\footnotesize ENGINE12]{..}). Always keep in mind that these things should be done consistently.

share|improve this answer
    
Isn't it possible to remove the gap that iam talking about without increasing the gap between images ? –  user581544 Aug 4 '12 at 17:31
    
as you can see on the image that i posted, there is a unnecessary gap between a) and EN- –  user581544 Aug 4 '12 at 17:38
    
@user581544: As mentioned, the width of the caption is based on the width of the image. Since the images are not as wide as the sub-captions, LaTeX introduces hyphenation and breaks them into two lines/rows. The easiest is to enlarge the image width "technically" (not physically). –  Werner Aug 4 '12 at 17:43
    
Unfortunately iam using double column format and increasing image width is not a option as it will then make the image overflow onto the next column. Is it possible to reduce the size of the caption text? –  user581544 Aug 4 '12 at 18:10
    
@user581544: You should then scale things based on \columnwidth rather than \textwidth. I've updated my answer to reflect this. –  Werner Aug 4 '12 at 18:37

Another option would be to use the subcaption package instead of the subfig package; using the former you can easily set the width of the box reserved for the subfloat and its caption independently from the width of the actual image:

\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{caption}
\usepackage{subcaption}

\begin{document}

\begin{figure}
\centering  
\subcaptionbox{ENGINE1\label{fig:gull4}}[.2\textwidth]{%
  \includegraphics[width=0.1\textwidth]{textures_data_types/lzw.eps}}%
\subcaptionbox{ENGINE12\label{fig:gull5}}[.2\textwidth]{%
  \includegraphics[width=0.1\textwidth]{textures_data_types/wav.eps}}%
\subcaptionbox{BITMAP\label{fig:gull6}}[.2\textwidth]{%
  \includegraphics[width=0.1\textwidth]{textures_data_types/bit.eps}}%  
\caption{Systems} 
\label{fig:bitmapVisualize2}
\end{figure}

\end{document}

enter image description here

Here's an example code using the twocolumn document option and showing the use of \captionsetup command to reduce the font size for the subfigures caption:

\documentclass[twocolumn]{article}
\usepackage[demo]{graphicx}
\usepackage{caption}
\usepackage{subcaption}

\begin{document}

\begin{figure}
\centering
\captionsetup[subfigure]{font=scriptsize}% reduces font size for subfigure captions  
\subcaptionbox{ENGINE1\label{fig:gull4}}[.3333\columnwidth]{%
  \includegraphics[width=0.1\columnwidth]{textures_data_types/lzw.eps}}%
\subcaptionbox{ENGINE12\label{fig:gull5}}[.3333\columnwidth]{%
  \includegraphics[width=0.1\columnwidth]{textures_data_types/wav.eps}}%
\subcaptionbox{BITMAP\label{fig:gull6}}[.3333\columnwidth]{%
  \includegraphics[width=0.1\columnwidth]{textures_data_types/bit.eps}}%  
\caption{Systems} 
\label{fig:bitmapVisualize2}
\end{figure}

\end{document}

enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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