如何正确对齐单元格内容?

如何正确对齐单元格内容?

我希望在某个表格中有一个单元格,其中包含环绕的文本和图形。表格本身需要几页。但是,可以tabularx很好地对齐两列的内容,而LTXtable不能。如果我没记错的话,tabularx 无法将表格拆分到多个页面上。我在 Ubuntu 下使用 TeXLive(如果这很重要的话)。我也尝试了其他几个软件包,但内容要么对齐(无法分页),要么可以分页(但内容不在一行中)。其他软件包也wrapfig没有帮助。

有可能达成“妥协”吗?

\documentclass[paper=a4,draft=false,fontsize=14pt,DIV=calc]{scrartcl}
\usepackage[ngerman]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{nag}
\usepackage{ltxtable}

\setlength{\parindent}{0pt}
\input{insbox}
\begin{document}

\LTXtable{\textwidth}{mwe_insbox_table.tex}

\begin{tabularx}{\linewidth}{lX}
    left column & {\InsertBoxR{0}{\begin{minipage}[t]{0.4\linewidth}\centering \rule{5cm}{5cm}\end{minipage}} Some silly text. Some silly text. Some silly text. Some silly text. Some silly text. Some silly text. Some silly text. Some silly text. Some silly text. Some silly text. Some silly text. Some silly text. Some silly text. Some silly text. Some silly text. Some silly text. Some silly text. Some silly text. Some silly text. Some silly text. Some silly text. Some silly text. Some silly text. Some silly text. Some silly text. Some silly text. Some silly text. Some silly text. Some silly text. Some silly text. Some silly text. }
\end{tabularx}

\end{document}

该文件mwe_insbox_table.tex包含:

\begin{longtable}{@{}lX@{}}
left column & {\InsertBoxR{0}{\begin{minipage}[t]{0.4\linewidth}\centering \rule{5cm}{5cm}\end{minipage}} Some silly text. Some silly text. Some silly text. Some silly text. Some silly text. Some silly text. Some silly text. Some silly text. Some silly text. Some silly text. Some silly text. Some silly text. Some silly text. Some silly text. Some silly text. Some silly text. Some silly text. Some silly text. Some silly text. Some silly text. Some silly text. Some silly text. Some silly text. Some silly text. Some silly text. Some silly text. Some silly text. Some silly text. Some silly text. Some silly text. Some silly text. }
\end{longtable}

答案1

如果您在单元格开头\ltablex添加指令和负垂直间距,它就会起作用。我还简化了您的代码:无需输入环境,输入列时:\keepXColumnsXminipage\@minipagetrueX

\documentclass[paper=a4,draft=false,fontsize=14pt,DIV=calc]{scrartcl}
\usepackage[ngerman]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{nag}
\usepackage{ltablex, makecell}
\usepackage[svgnames]{xcolor}
\setlength{\parindent}{0pt}
\input{insbox}
    \makeatletter
    \newcommand*{\compress}{\@minipagetrue}
    \makeatother

\begin{document}

\keepXColumns
\begin{tabularx}{\linewidth}{l>{\compress\arraybackslash}X}
   left column &
   \vspace*{-\baselineskip} \InsertBoxR{0}{{\color{Tomato}\rule{5cm}{5cm}}} Some silly text. Some silly text. Some silly text. Some silly text. Some silly text. Some silly text. Some silly text. Some silly text. Some silly text. Some silly text. Some silly text. Some silly text. Some silly text. Some silly text. Some silly text. Some silly text. Some silly text. Some silly text. Some silly text. Some silly text. Some silly text. Some silly text. Some silly text. Some silly text. Some silly text. Some silly text. Some silly text. Some silly text. Some silly text. Some silly text. Some silly text.
\end{tabularx}

\end{document}

在此处输入图片描述

相关内容