如题,希望实现 双栏文本-单栏表格-双栏文本 的文章结构
下面的mwe使用了multicols
宏包实现,但是不够优雅,需要根据文本内容的多少来手动调整,希望使用标准文档类twocolumn
和onecolumn
的选项切换来实现。
\documentclass[a4paper]{article}
\usepackage[margin=.5in]{geometry}
\usepackage{lipsum}
\usepackage{multicol}
\usepackage{tabularray}
\usepackage{float}
\UseTblrLibrary{booktabs}
\begin{document}
\begin{multicols}{2}
\lipsum[1-2]
\end{multicols}
\begin{table}[h]
\centering
\begin{tblr}{
vlines,cells={valign=m},
colspec = {*{8}{Q[1.75cm,c]}},
cells = {font=\tiny},
row{1,2}={font=\bfseries\small},
column{1}={font=\bfseries\small},
abovesep=0pt, belowsep=2pt, rowsep=2pt,
}
\toprule
\SetCell[r=2]{m} Dataset & \SetCell[r=2]{m} Embedding Capacity (bits) & \SetCell[c=6]{m} Extraction Error (\%) \\
\midrule
& & Addition and Deletion of Punctuation Marks & Addition and Deletion of Stop Words & Synonym Replacement & Random Word Insertion & Character Deletion and Swapping & Word Order Reversal \\
\midrule
AG News & 30,000 & 0 & 0 & 0 & 0 & 2.92 & 0.26 \\
\midrule
Dbpedia & 90,000 & 0 & 0 & 0 & 1.27 & -- & -- \\
\bottomrule
\end{tblr}
\end{table}
\begin{multicols}{2}
\lipsum[3-4]
\end{multicols}
\end{document}
效果:
预期:希望找到一种更优雅的方法:实现无需手动调整\multicols
的位置,自动实现将表格插入双栏文章整体的对应位置,并自动调整前后的文本,避免下图出现这种情况:
可以将tblr环境放入strip环境里,该环境由cuted这个包提供,注意的是strip里面不要放入浮动体
代码如下:
\documentclass[a4paper,twocolumn]{article}
\usepackage[margin=.5in]{geometry}
\usepackage{lipsum}
\usepackage{multicol}
\usepackage{tabularray}
\usepackage{float}
\usepackage{cuted}
\UseTblrLibrary{booktabs}
\begin{document}
\lipsum[1-2]
\begin{strip}
\centering
\begin{tblr}{
vlines,cells={valign=m},
colspec = {*{8}{Q[1.75cm,c]}},
cells = {font=\tiny},
row{1,2}={font=\bfseries\small},
column{1}={font=\bfseries\small},
abovesep=0pt, belowsep=2pt, rowsep=2pt,
}
\toprule
\SetCell[r=2]{m} Dataset & \SetCell[r=2]{m} Embedding Capacity (bits) & \SetCell[c=6]{m} Extraction Error (\%) \\
\midrule
& & Addition and Deletion of Punctuation Marks & Addition and Deletion of Stop Words & Synonym Replacement & Random Word Insertion & Character Deletion and Swapping & Word Order Reversal \\
\midrule
AG News & 30,000 & 0 & 0 & 0 & 0 & 2.92 & 0.26 \\
\midrule
Dbpedia & 90,000 & 0 & 0 & 0 & 1.27 & -- & -- \\
\bottomrule
\end{tblr}
\end{strip}
\lipsum[3-4]
\end{document}
编译效果如图:
谢谢,确实在这种情况下
cuted
提供的strip
环境很合适而且有效。