Graphics, Figures & TablesSub-float Issue

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
TMorville
Posts: 16
Joined: Thu Mar 14, 2013 4:58 pm

Sub-float Issue

Post by TMorville »

Hi, im relativly new to LyX and all new to latex. This problem has been buggering me too long, and i can't seem to find a solution.

I have a problem with the subfloat command, when i have two subfloats in one figurefloater, i get this error message:

Code: Select all

Argument of \sf@@@subfloat has an extra }.
And this only happens after I've added the figures. I.e. i can execute with no problems before i add the figures.

Here is the ERT code:

Code: Select all

\begin{figure}[H] 
\caption{} 
\subfloat[{\includegraphics[scale=0.1]{indsat7}}]{}
\hfill{}
\hfill{}
\subfloat[{\includegraphics[scale=0.1]{indsat8}}]{} 
\end{figure}
And I've looked to these forum posts, without luck.

http://latex-community.org/forum/viewto ... 45&t=18244
http://latex-community.org/forum/viewto ... =19&t=6136

Hope you can help me!
Last edited by cgnieder on Thu Mar 14, 2013 8:47 pm, edited 1 time in total.

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

Sub-float Issue

Post by localghost »

Your (ERT*) code should read like this. Untested since I'm not a LyX user.

Code: Select all

\begin{figure}[!ht]
  \subfloat[First sub-float\label{subfig-1:subfloats}]{
    \includegraphics[scale=0.1]{indsat7}
  }
  \hfill
  \subfloat[First sub-float\label{subfig-2:subfloats}]{
    \includegraphics[scale=0.1]{indsat8}
  }
  \caption{fig:subfloats}
  \label{fig:sub-floats}
\end{figure}
For details consult the subfig manual.


Best regards and welcome to the board
Thorsten

____________
* What does ERT mean?
User avatar
sommerfee
Posts: 503
Joined: Mon Apr 09, 2007 4:20 pm

Re: Sub-float Issue

Post by sommerfee »

TMorville, you have inserted the images into the sub-figure description text (caption), not into the sub-figure content itself (where they belong instead).

(Just to summarize what Thorsten is trying to tell you :) )
TMorville
Posts: 16
Joined: Thu Mar 14, 2013 4:58 pm

Sub-float Issue

Post by TMorville »

Hi guys, and thanks for the warm welcome :-)

I believe ERT is "Evil red text" code?

Anyway, the way i posted it, is how LyX translates it to texcode i guess..

I did it manually, and then via. view->view source, i found the embedded code.

And thanks for the input Thorsten, but that dident work either, now i get this error message:

Code: Select all

\subfloat
                [First sub-float\label{subfig-1:subfloats}]{
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.
Any ideas?

T
Last edited by cgnieder on Fri Mar 15, 2013 2:45 pm, edited 1 time in total.
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Sub-float Issue

Post by cgnieder »

TMorville wrote:I believe ERT is "Evil red text" code?
Yes that's true. That is how TeX code is called in LyX.

Have you added \usepackage{subfig} to your preamble? (Document > Settings > LaTeX Preamble)

Regards
site moderator & package author
TMorville
Posts: 16
Joined: Thu Mar 14, 2013 4:58 pm

Re: Sub-float Issue

Post by TMorville »

That worked beautifully together with Thorstens code!

I had no idea that i had to add the packages to the documentclass, for them to work properly. I though that all installed packages were "global"..

Thanks a bunch :)
TMorville
Posts: 16
Joined: Thu Mar 14, 2013 4:58 pm

Sub-float Issue

Post by TMorville »

Just to clarify, it worked beautifully until i changed the path of my figures...

Now i get the entire patch to that figure, inside the figure caption, AND the label does not seem to work with the crossreference system in LyX either.. Sigh!

Code: Select all

\begin{figure}[H]   
	\subfloat[First sub-float\label{subfig-1:subfloats}]{     
		\includegraphics[scale=0.1]{C:/Users/Tobias/Dropbox/Axiomatic model/Figures/stupid evo.png}   
}   
	\hfill   
	\subfloat[First sub-float\label{subfig-2:subfloats}]{     
		\includegraphics[scale=0.1]{C:/Users/Tobias/Dropbox/Axiomatic model/Figures/stupid evo.png}   
}   
	\caption{fig:subfloats}  
	\label{fig:sub-floats} 
\end{figure}
I.e. it includes "C:/Users/Tobias/Dropbox/Axiomatic model/Figures/stupid evo.png" under the figure text, which is very annoying.

Any advice how to fix this? I've googled the subfig command and looked at examples, but no luck!

best,
Tobias
Last edited by cgnieder on Mon Mar 18, 2013 8:03 pm, edited 1 time in total.
User avatar
sommerfee
Posts: 503
Joined: Mon Apr 09, 2007 4:20 pm

Re: Sub-float Issue

Post by sommerfee »

Avoid file paths with spaces in it.
TMorville
Posts: 16
Joined: Thu Mar 14, 2013 4:58 pm

Re: Sub-float Issue

Post by TMorville »

Aaaaaand that worked.

Thanks!
Post Reply