我是入门级 LaTex 用户。我有一张横跨整个页面的横向表格,但由于它不是很大,所以最好将文本放在旁边。
这是我的最小工作示例:
\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.4\textwidth}{!}{%
\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}
我尝试了wraptable
,但是它返回错误:improper \predevdepth. Missing \endgroup inserted. Missing } inserted
在\begin{landscape}
和Latex Error: Not in outer par mode. Undefined control sequence. Missing number, treated as 0
在\begin{table}
。
这是我心中想法的一个例证:
答案1
这里有一种方法......但是你必须知道把桌子放在哪里以及在桌子旁边放什么。
\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}
}}
\noindent\begin{minipage}[t]{\wd\testBox}\vspace{0pt}\usebox{\testBox}\end{minipage}\hfill\begin{minipage}[t]{\dimexpr\linewidth-\wd\testBox-5mm}\vspace{0pt}
\lipsum[1-3]
\end{minipage}
\end{document}
答案2
另一种解决方案是使用 tcolorbox 包:
\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}