TransWikia.com

How to display a horizontal table next to a page of text

TeX - LaTeX Asked on August 14, 2021

I’m an entry-level LaTex user. I have a table in landscape orientation that spans a whole page, but as it’s not very large, it would be nice to have the text next to it.

Here is my minimum working example:

documentclass{article}
usepackage[utf8]{inputenc}
usepackage[a4paper, total={16.5cm, 23cm}]{geometry}
usepackage{lipsum}
usepackage{lscape}
usepackage{graphicx}
usepackage{wrapfig}

begin{document}
 
lipsum[2-8]

begin{wraptable}{l}{0pt}% automatically uses minimum width
begin{landscape}
begin{table}[]
resizebox{1.4textwidth}{!}{%
begin{tabular}{|llllllll|} 
hline
Header & Header & Header & Header & Header & Header & Header & Header   
hline
LaTex  & LaTex  & LaTex  & LaTex  & LaTex  & LaTex  & LaTex  & LaTex    
hline
LaTex  & LaTex  & LaTex  & LaTex  & LaTex  & LaTex  & LaTex  & LaTex   
hline
end{tabular}
}
caption{This is a Caption}
end{table}
end{landscape}
end{wraptable}

end{document}

I tried wraptable, but it returned errors: improper predevdepth. Missing endgroup inserted. Missing } inserted at begin{landscape} and Latex Error: Not in outer par mode. Undefined control sequence. Missing number, treated as 0 at begin{table}.

This is an illustration of what I had in mind:

enter image description here

2 Answers

Here is a way ... but you have to know where to place the table and what to place next to it.

documentclass{article}
usepackage[utf8]{inputenc}
usepackage[a4paper, total={16.5cm, 23cm}]{geometry}
usepackage{lipsum}
usepackage{lscape}
usepackage{graphicx}
usepackage{rotating}
usepackage{capt-of}

newsavebox{testBox}

begin{document}
 
lipsum[2-8]

savebox{testBox}{rotatebox{90}{%
begin{minipage}[b]{textheight}
begin{tabular*}{textheight}{|l@{extracolsep{fill}}lllllll|} 
hline
Header & Header & Header & Header & Header & Header & Header & Header   
hline
LaTex  & LaTex  & LaTex  & LaTex  & LaTex  & LaTex  & LaTex  & LaTex    
hline
LaTex  & LaTex  & LaTex  & LaTex  & LaTex  & LaTex  & LaTex  & LaTex   
hline
end{tabular*}
captionof{table}{This is a Caption}
end{minipage}
}}

noindentbegin{minipage}[t]{wdtestBox}vspace{0pt}usebox{testBox}end{minipage}hfillbegin{minipage}[t]{dimexprlinewidth-wdtestBox-5mm}vspace{0pt}
lipsum[1-3]
end{minipage}

end{document}

Correct answer by koleygr on August 14, 2021

An other solution usign tcolorbox package :

documentclass{article}
usepackage[utf8]{inputenc}
usepackage[a4paper, total={16.5cm, 23cm}]{geometry}
usepackage{lipsum}
usepackage{graphicx}
usepackage{tcolorbox}
tcbuselibrary{skins}

begin{document}

begin{tcolorbox}[enhanced, sidebyside, lefthand ratio=.3,
  sidebyside align=center]
    rotatebox{90}{
      begin{tabular}{|llllllll|} 
        hline
        Header & Header & Header & Header & Header & Header & Header & Header   
        hline
        LaTex  & LaTex  & LaTex  & LaTex  & LaTex  & LaTex  & LaTex  & LaTex    
        hline
        LaTex  & LaTex  & LaTex  & LaTex  & LaTex  & LaTex  & LaTex  & LaTex   
        hline
      end{tabular}
    }
    tcblower
    lipsum[2-5]
end{tcolorbox}

end{document}

enter image description here

Answered by flav on August 14, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP