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.

My problem is quite similar to the one described in Problems with landscape mode and Title on the same page. The hvfloats solution suggested there does not work for me, however, because I use multiple subtables. But let me start from the beginning:

In the appendix of my thesis I want to add a wide table that needs to be set in landscape mode. Normally I'd just use the sidewaystable environment, but that leaves the first page of the appendix completely empty except for the chapter heading

\documentclass[a4paper] {scrbook}

\usepackage{rotating}
\usepackage{subcaption}

\begin{document}

\appendix \cleardoublepage
\chapter{Some Data Tables}

\begin{sidewaystable}
  \hspace*{\fill}
  \begin{subtable}{.3\textwidth}
    \rule{\linewidth}{12cm}
  \end{subtable}
  %
  \hspace*{\fill}
  %
  \begin{subtable}{.3\textwidth}
    \rule{\linewidth}{12cm}
  \end{subtable}
  \hspace*{\fill}

  \caption{Table with interesting data}
\end{sidewaystable}

\end{document}

The purpose of the three \hspace*{\fill} is just to center the resulting tables properly on the page.


Realising that sidewaystable refers to \textheight I also tried to temporarily adjust that

\def \textheightTmp \textheight
\def \textheight 0.8\textheightTmp
\begin{sidewaystable}
  [...]
\end{sidewaystable}
\def \textheight \textheightTmp

but this lead to the following error

Appendix A.

! Package caption Error: \setcaptionsubtype outside float.

See the caption package documentation for explanation. Type H for immediate help. ...

l.15 \begin{subtable}{.3\textwidth}


As I mentioned at the beginning, hvfloats does not work either because of the subtables

\documentclass[a4paper] {scrbook}

\usepackage{hvfloat}
\usepackage{subcaption}

\begin{document}

\appendix \cleardoublepage
\chapter{Some Data Tables}

\hvFloat[capPos=b,rotAngle=90,nonFloat]{table}{%
  \hspace*{\fill}
  \begin{subtable}{.3\textwidth}
    \rule{\linewidth}{12cm}
  \end{subtable}
  %
  \hspace*{\fill}
  %
  \begin{subtable}{.3\textwidth}
    \rule{\linewidth}{12cm}
  \end{subtable}
  \hspace*{\fill}
}{Table with interesting data}{}

\end{document}

This results in the error:

Appendix A.

! Package caption Error: \setcaptionsubtype outside float.

See the caption package documentation for explanation. Type H for immediate help. ...

l.23 }{Table with interesting data}{}


What I want is a rotated table (with subtables) and caption that is placed on the same page as the chapter heading. Space isn't an issue, the table would fit on the page.

Is there any way to do this?

share|improve this question
    
hvfloat does work properly when I replace subtable with minipage and set the subcaptions manually with \captionof{subtable}. But then there are 3 new problems: 1. spacing is not correct (too much space between table and subcaption and between subcaption and caption) 2. the subcaption format is not consistent with that of regular subtables 3. all (some?) the hspace commands are ignored and the tables are off center and very close together –  TableKing Jul 2 '13 at 13:22
    
I continued my experiments with hvfloat and just loading the package is enough to distort the caption spacing of tables that comprise subtables :-( –  TableKing Jul 2 '13 at 23:06

1 Answer 1

up vote 4 down vote accepted

You are facing two problems here:

  1. The hvfloat package does not set \@captype (like an ordinary floating environment does) so the subcaption package has no idea if its commands are used inside a figure, a table, or not within a floating environment at all. This must be fixed by Herbert, however you could use \captionsetup{type=table} as workaround.
  2. The standard document classes set \abovecaptionskip to a value of 10pt, \belowcaptionskip to 0pt. \abovecaptionskip will be used above the caption, and \belowcaptionskip below of it. However, this gives you a obvious problem when a \caption is typeset above a figure or table content since you will get a distance of \belowcaptionskip (=0pt) between caption and content, i.e. no distance of all. There are two different (and incompatible) ways to resolve this situation:

    • \abovecaptionskip will be used between caption and content, \belowcaptionskip will be used between caption and edge of the floating environment. (This has the advantage that you could use the default values of \abovecaptionskip and \belowcaptionskip as set by the document class, and the result will not change at all when using \caption below its contents, as designed by Leslie Lamport.)

    • If the caption is below its content, only \abovecaptionskip is used. If the caption is above its content, only \belowcaptionskip is used. (The skips need to be adjusted for making this work, but you are able to setup different skips for above-captions and below-captions here.)

As you see both methods have its pros and cons, but are unfortunately incompatible. However, KOMA-Script and the (sub)caption package are using the first method while hvfloat seems to use the latter. (I'm not sure about this since I didn't have found the time to look into Herbers sources, but at least hvfloat changes the values of the caption skips and therefore just loading the package will affect the skips of the non-hvfloat-floating environments (and the longtable environment and...) as well.)

To compensate this one needs to write macros to save and restore the skips.

So in total we have:

\documentclass[a4paper] {scrbook}

% Save the values of \abovecaptionskip and \belowcaptionskip into \restorecaptionskips
\edef\restorecaptionskips{%
  \noexpand\setlength\noexpand\abovecaptionskip{\the\abovecaptionskip}%
  \noexpand\setlength\noexpand\belowcaptionskip{\the\belowcaptionskip}}
%\show\restorecaptionskips
\usepackage{hvfloat}
% Save the changed values of \abovecaptionskip and \belowcaptionskip into \restorehvcaptionskips
\edef\restorehvcaptionskips{%
  \noexpand\setlength\noexpand\abovecaptionskip{\the\abovecaptionskip}%
  \noexpand\setlength\noexpand\belowcaptionskip{\the\belowcaptionskip}}
% Restore the values of \abovecaptionskip and \belowcaptionskip
\restorecaptionskips

\usepackage{subcaption}

\begin{document}

\appendix \cleardoublepage
\chapter{Some Data Tables}

\restorehvcaptionskips % only needed if "capPos=t"
\hvFloat[capPos=b,rotAngle=90,nonFloat]{table}{%
\restorecaptionskips
\captionsetup{type=table}% set \@captype
  \hspace*{\fill}
  \begin{subtable}{.3\textwidth}
    \rule{\linewidth}{12cm}
  \end{subtable}
  %
  \hspace*{\fill}
  %
  \begin{subtable}{.3\textwidth}
    \rule{\linewidth}{12cm}
  \end{subtable}
  \hspace*{\fill}
}{Table with interesting data}{}
\restorecaptionskips

\end{document}

P.S.: See also http://sourceforge.net/p/latex-caption/tickets/4/

share|improve this answer
    
Thanks for the detailled explanation! I think \noexpand\setlength\noexpand\abovecaptionskip{\the\belowcaptionskip} should actually read \noexpand\setlength\noexpand\belowcaptionskip{\the\belowcaptionskip}. Otherwise it doesn't make much sense. The hspace commands are still ignored, but I think I can live with that. –  TableKing Jul 3 '13 at 11:02
    
It just occured to me that the hspace is likely not working because the hvFloat just cannot know the size I expect it to fill. I will try and add an additional minipage that has this size and contains the actual table... –  TableKing Jul 3 '13 at 11:12
    
@TableKing Yes, of course you are correct, will correct the answer right now. –  Axel Sommerfeldt Jul 3 '13 at 19:34

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.