1

i have a question about longtables. Is it possible to get a text wrapped around a (right-situated) longtable? I am using the longtable package and this is my code:

  \begin{longtable}[r]{| r | r | r |}
 \caption{some caption)\\

\hline
 \multicolumn{3}{| r |}{Heading}\\
 \hline
 \large bla & bla & bla \\
 \hline
  \endfirsthead
   \hline
 \endhead

 \hline
 \endfoot
 \hline


 \multicolumn{3}{| r |}{Reference
 \footnotesize{*Estimation}}\\
 \hline\hline
 \endlastfoot

Incidence   & &\\
1958-1962: & number  & number  \\
2013-2017 & number & number \\
\cline{1-3}
Text  & &\\
1978-1982 & number & number \\
2013-2017& number & number* \\

 \end{longtable}
 \label{table:somename}

I would greatly appreciate if someone can help me.

SGS
  • 43

1 Answers1

1

First step, determine the height and width needed.

\documentclass{article}
\begin{document}
\sbox0{\begin{tabular}{| r | r | r |}
 \multicolumn{3}{| r |}{Reference
 \footnotesize{*Estimation}}\\
 \hline\hline
Incidence   & &\\
1958-1962: & number  & number  \\
2013-2017 & number & number \\
\cline{1-3}
Text  & &\\
1978-1982 & number & number \\
2013-2017& number & number* \\
\end{tabular}}

height=\the\textheight

width=\the\wd0
\end{document}

Next step, store the longtable in a separate document.

\documentclass{article}
\usepackage[margin=0pt,paperheight=550pt,paperwidth=153.2781pt,noheadfoot]{geometry}
\usepackage{longtable}
\begin{document}
%\setcounter{table}{2}
\begin{longtable}{| r | r | r |}
 \caption{some caption}\\
\hline
 \multicolumn{3}{| r |}{Heading}\\
 \hline
 \large bla & bla & bla \\
 \hline
  \endfirsthead
   \hline
 \endhead
 \hline
 \endfoot
 \hline
 \multicolumn{3}{| r |}{Reference
 \footnotesize{*Estimation}}\\
 \hline\hline
 \endlastfoot
Incidence   & &\\
1958-1962: & number  & number  \\
2013-2017 & number & number \\
\cline{1-3}
Text  & &\\
1978-1982 & number & number \\
2013-2017& number & number* \\
\end{longtable}
\end{document}

Step 3, insert the pages into your document.

\documentclass{article}
\usepackage{wrapfig}
\usepackage{graphicx}
\usepackage{lipsum}
\begin{document}
\begin{wrapfigure}{r}{0pt}
  \refstepcounter{table}\label{table:somename}%
  \includegraphics[page=1]{test5}% document stored as test5.pdf
\end{wrapfigure}
\sloppy
\lipsum[1-2]
\end{document}

or

\documentclass{article}
\usepackage{paracol}
\globalcounter{table}
\usepackage{graphicx}
\usepackage{lipsum}
\begin{document}
\setcolumnwidth{\dimexpr \textwidth-\columnsep-153.2781pt\relax,153.2781pt}
\begin{paracol}{2}
\sloppy
\lipsum[1-2]
\switchcolumn
\refstepcounter{table}\label{table:somename}%
\includegraphics[page=1]{test5}% document stored as test5.pdf
\end{paracol}
\end{document}

There is no good way to start and stop the text wrap, unless they happen at paragraph boundaries. You can break a paragraph at the top of a page by inserting wrapfigure at precisely the right spot. Each image should be 550pt high, even the last page. You can end the wrap early using \WFclear, but only between paragraphs.

You will also need to manually insert an entry into the list of tables, or possibly use the xr package to copy the entry from test5.aux.

John Kormylo
  • 79,712
  • 3
  • 50
  • 120