Text Formattingsubfig package

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
gkl
Posts: 28
Joined: Sat Jan 17, 2009 12:21 am

subfig package

Post by gkl »

Dear All,

I am using subfig to have four images on two lines, two images per line. Below is my code:

Code: Select all

\begin{figure}[h!]
\centering
\subfloat[Full Protocol]{\label{fig:42a}\input{xfig/figure42a.pdftex_t}} 
\subfloat[First Protocol]{\label{fig:42b}\input{xfig/figure42b.pdftex_t}}\\
\subfloat[Second Protocol]{\label{fig:42c}\input{xfig/figure42c.pdftex_t}}
\subfloat[Fourth Protocol]{\label{fig:42d}\input{xfig/figure42d.pdftex_t}} \caption{Four Images}
\label{fig:nonimplementableprotocol}
\end{figure}
Now when the code runs, I get the following screenshot:
subfig.gif
subfig.gif (14.49 KiB) Viewed 3802 times
i.e. the first image on the second line starts from a lower point than the others.

Could someone give me a pointer as to how to fix this (all figures are drawn in XFig and they are all located at the top left of the file).

Regards,
George


Edit by localghost: Preferably no external links (see Board Rules). Attachments go onto the forum server where possible.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Re: subfig package

Post by localghost »

You could add some vertical space in the concerned sub-float after the actual image.


Thorsten
gkl
Posts: 28
Joined: Sat Jan 17, 2009 12:21 am

subfig package

Post by gkl »

You mean like this?

Code: Select all

\subfloat[Second Protocol]{\label{fig:42c}\input{xfig/figure42c.pdftex_t\vspace*{\medskipamount}}}
?

Unfortunately it did not work. I tried doing this inside the pdftex_t file, but still no luck.

Many thanks for your offer to help.

George
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

subfig package

Post by localghost »

Try another package like »subcaption« (from the caption bundle) or floatrow. These packages should master vertical alignment.
Frits
Posts: 169
Joined: Wed Feb 02, 2011 6:02 pm

subfig package

Post by Frits »

If the method of localghost didn't work out, there's another workaround by putting a picture environment inside your figure environment. This is explained here.

Code: Select all

\begin{figure}[h!]
\setlength{\unitlength}{1mm}
\centering
\begin{picture}(x,y)
\put(x1,y1){\subfloat[Full Protocol]{\label{fig:42a}\input{xfig/figure42a.pdftex_t}}}
\put(x2,y2){\subfloat[First Protocol]{\label{fig:42b}\input{xfig/figure42b.pdftex_t}}}
\put(x3,y3){\subfloat[Second Protocol]{\label{fig:42c}\input{xfig/figure42c.pdftex_t}}}
\put(x4,y4){\subfloat[Fourth Protocol]{\label{fig:42d}\input{xfig/figure42d.pdftex_t}}} \caption{Four Images}
\label{fig:nonimplementableprotocol}
\end{figure}
It's a bit like trial and error, but eventually will work. You'll need to rebuild your document over and over to find the right values for x,y,x1,y1,x2,and so on.
howtoTeX.com - Your LaTeX resource site (Tips, Tricks, Templates and more!)
Follow howtoTeX on twitter
Post Reply