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 a situation where the subfigure caption doesn't start at the start of the line. \captionsetup[table]{width=\textwidth} is added to try to have the caption take up the whole line rather than wrap at the boundaries of the table as recommended in Prevent wrapping of subtable captions in lyx.

enter image description here

%% LyX 1.6.7 created this file.  For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.
\documentclass[english]{article}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}

\makeatletter

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands.
%% Because html converters don't know tabularnewline
\providecommand{\tabularnewline}{\\}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
\usepackage{caption}
\usepackage{subfig}
\captionsetup[table]{width=\textwidth}

\@ifundefined{showcaptionsetup}{}{%
 \PassOptionsToPackage{caption=false}{subfig}}
\usepackage{subfig}
\makeatother

\usepackage{babel}

\begin{document}
%
\begin{table}
\caption{Valleys in promoters of genes correlated with overexpression by breast
cancer subtype}


\label{tab:vlyTallyUniqVlyMtchCntrlOvrExp}

\subfloat[Number of valleys in the promoter region marking overexpresses genes
in breast cancer by subtype]{\begin{raggedright}

\par\end{raggedright}

\begin{raggedright}
\label{tab:vlyTallyUniqCombinedVlyMtchCntrlOvrExp}
\par\end{raggedright}

\raggedright{}\begin{tabular}{|c|c|c|c|}
\cline{3-4} 
\multicolumn{1}{c}{} &   & \multicolumn{2}{c|}{Over-expression}\tabularnewline
\cline{3-4} 
\multicolumn{1}{c}{} &  & Basal & Luminal \tabularnewline
\hline 
Marked & Basal  & 131  & 116\tabularnewline
\cline{2-4} 
Cell line & Luminal  & 100  & 104\tabularnewline
\hline
\end{tabular}}

\subfloat[Directly overlapping valleys in promoters of genes correlated with
overexpression by breast cancer subtype]{\begin{raggedright}

\par\end{raggedright}

\begin{raggedright}
\label{tab:vlyTallyUniqOverlappingVlyMtchCntrlOvrExp}
\par\end{raggedright}

\raggedright{}\begin{tabular}{|c|c|c|c|}
\cline{3-4} 
\multicolumn{1}{c}{} &   & \multicolumn{2}{c|}{Over-expression}\tabularnewline
\cline{3-4} 
\multicolumn{1}{c}{} &  & Basal & Luminal \tabularnewline
\hline 
Marked & Basal  & 26 & 18\tabularnewline
\cline{2-4} 
Cell line & Luminal  & 20 & 10\tabularnewline
\hline
\end{tabular}}
\end{table}




\end{document}
share|improve this question
1  
Well, the reason that this happens was essentially described in my comment to the answer in that other post: you manually changed the \width which causes an overfull \hbox. It overflows symmetrically to the left and the the right, which is why when everything is centered it looks alright. But now that you have everything flush left, overflowing to the left and right symmetrically causes a problem. Suggestion: look at the other things you are allowed to set with \captionsetup. See if you can actually set the right margin to some negative value to compensate. –  Willie Wong Jan 25 '11 at 19:56
    
interesting analysis @Willie Wong. It is mostly over my head right now and I cannot research more about the tex internals right now but this comment is helpful. When I get more time I will learn more. –  denilw Jan 26 '11 at 23:33

1 Answer 1

up vote 2 down vote accepted

write after your \begin{figure} a \centering or in LyX mark the contents of the float and choose centering

share|improve this answer
    
+1 thanks for the reply. I don't know how to "mark the contents of the float and choose centering". The only thing I could do is left click on the float -> select Paragraph settings -> select center in the Alignment section. I don't think this is what you are asking me to do. –  denilw Jan 25 '11 at 22:44
    
yes, that would also be ok, but it insert a \begin{center}...\end{center} environment. Better is a single command \centering. Don't know how it can be insert in LyX –  Herbert Jan 26 '11 at 8:14
    
In my example, in Kile, adding \centering after \begin{table} doesn't do anything. What effect did it have for you? –  denilw Jan 26 '11 at 17:35
    
@denilw: see archiv.dante.de/~herbert/zz.pdf –  Herbert Jan 26 '11 at 17:38
    
works now, I must have made some kind of silly mistake before. –  denilw Jan 26 '11 at 23:27

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.