4

I have a figure and a table placed next to one another, but they are wider than the textwidth. Now I want to center them so they exceed the textwidth margins. Can this be done?

Edit: currently I have something like this, but I can't seem to get this wider than the textwidth.

\begin{figure}
\begin{floatrow}
\ffigbox{%
 \includegraphics[height=5cm]{figure}
}{%
  \caption{figure caption}%
  \label{figure}
}
\capbtabbox{%
\begin{tabular}{ |c|}
  HERE COMES THE TABLE
\end{tabular}
}{%
  \caption{table}%
}
\end{floatrow}
%\vspace{-1cm}
\end{figure}
  • 1
    Please post a Mininal Working Example (MWE)! – Jagath Jul 28 '13 at 13:52
  • possible duplicate of Center figure that is wider than \textwidth – Thorsten Donig Jul 28 '13 at 14:00
  • @ThorstenDonig But how to do this with a table and a figure (instead of 2 figs)? – MaVe Jul 28 '13 at 14:03
  • My comment was based on the first version of your question which did not contain any code. A self-contained and minimal example could help to solve the problem. A code snippet is not very helpful. – Thorsten Donig Jul 28 '13 at 14:19
4

Using \DeclareMarginSet, you can declare a margin set allowing you to hang the object on both margins (there are predefined settings hangleft, hangright for each margin individually, but not for both of them simultaneouly); then, you can invoke this margin set together with an appropriate value for floatwidth and rowfill=yes. Something along these lines:

\documentclass{article}
\usepackage{graphicx}
\usepackage{floatrow}
\usepackage{lipsum}% just to generate text for the example

\DeclareMarginSet{hangboth}{\setfloatmargins*{\hskip-4cm}{\hskip-4cm}}

\begin{document}

\thisfloatsetup{floatwidth=\paperwidth,rowfill=yes,margins=hangboth}
\lipsum[4]
\begin{figure}[!ht]\CenterFloatBoxes
\begin{floatrow}
\ffigbox[\FBwidth]
  {\includegraphics[width=10cm,height=4cm]{example-image-a}}
  {\caption{figure caption}\label{figure}}
\ttabbox[\FBwidth]
  {\begin{tabular}{lll}
  column1a & column2a & column3a \\
  column1b & column2b & column3b \\
  column1c & column2c  & column3c \\
  column1d & column2d & column3d
  \end{tabular}}
  {\caption{table}}
\end{floatrow}
\end{figure}
\lipsum[4]

\end{document}

enter image description here

The option [!ht] was only used for the example; I am bot recommending its use.

To have the caption for the table below it (although it's usual for table captions to appear above the table), you can use \floatbox instead of \ttabbox for the table and perhaps do some additional adjustment for the vertical alignment using heightadjust and valign:

\documentclass{article}
\usepackage{graphicx}
\usepackage[rawfloats]{floatrow}
\usepackage{lipsum}

\DeclareMarginSet{hangboth}{\setfloatmargins*{\hskip-4cm}{\hskip-4cm}}

\begin{document}

\thisfloatsetup{floatwidth=\paperwidth,rowfill=yes,margins=hangboth,heightadjust=all,valign=b}
\lipsum[4]
\begin{figure}[!ht]
\begin{floatrow}
\ffigbox[\FBwidth]
  {\includegraphics[width=10cm,height=4cm]{example-image-a}}
  {\caption{figure caption}\label{figure}}
\floatbox{table}[\FBwidth]
  {\caption{table}}
  {\begin{tabular}{lll}
  column1a & column2a & column3a \\
  column1b & column2b & column3b \\
  column1c & column2c & column3c \\
  column1d & column2d & column3d
  \end{tabular}}
\end{floatrow}
\end{figure}
\lipsum[4]

\end{document}

enter image description here

  • Thanks, that's what I needed. Any idea on how to put the caption under the table? – MaVe Jul 28 '13 at 15:12
  • @MaVe: Tables have their captions above. – Thorsten Donig Jul 28 '13 at 15:15
  • @ThorstenDonig And can you force the caption to be under the table? – MaVe Jul 28 '13 at 15:16
  • 1
    @MaVe please see my updated answer. – Gonzalo Medina Jul 28 '13 at 16:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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