![\newenvironment 或 \newcommand 用于 \xltabular](https://linux22.com/image/412388/%5Cnewenvironment%20%E6%88%96%20%5Cnewcommand%20%E7%94%A8%E4%BA%8E%20%5Cxltabular.png)
我希望有一个快捷方式来触发表格,如 tabularx,并带有多页选项,如 longtable。我\newenvironment
和他们都\newcommand
无法说服它工作
@..
xltabular 设置开始时的奇怪构造是为了丢弃以其他方式添加的缩进。实际文档之前的所有内容都位于类文件中,如果这有区别的话。解释器需要是 XeLaTex。似乎没有 begin/end xltabular 的命令版本,这是解决环境问题的方法tabularx-案例。
M(n)WE:
\documentclass[10pt]{article}
\usepackage{xltabular} % mixture of tabularx and longtable
%% Either like this (1)
%\newenvironment{threetable}
%{\begin{xltabular}{\linewidth}{@{} X @{\hspace{20pt}} X @{\hspace{20pt}} X @{}}} {\end{xltabular}}
%% Or like this (2)
%\newcommand{\startthreetable}{\begin{xltabular}{\linewidth}{@{} X @{\hspace{20pt}} X @{\hspace{20pt}} X @{}}}
%\newcommand{\stopthreetable}{\end{xltabular}}
\begin{document}
\begin{xltabular}{\linewidth}{@{} X @{\hspace{20pt}} X @{\hspace{20pt}} X @{}}
Content & content & CONTENT
\end{xltabular}
%% (1)
%\begin{threetable}
%Content & content & CONTENT
%\end{threetable}
%% (2)
%\startthreetable
%Content & content & CONTENT
%\stopthreetable
\end{document}
答案1
正如手册中所述tabularx
(xltabular
基本上是一个tabularx
要合并的包装器longtable
),您需要使用环境定义中的命令形式
\documentclass[10pt]{article}
\usepackage{xltabular} % mixture of tabularx and longtable
\newenvironment{threetable}
{\xltabular{\linewidth}{@{} X @{\hspace{20pt}} X @{\hspace{20pt}} X @{}}} {\endxltabular}
\begin{document}
\begin{xltabular}{\linewidth}{@{} X @{\hspace{20pt}} X @{\hspace{20pt}} X @{}}
Content & content & CONTENT
\end{xltabular}
\begin{threetable}
Content & content & CONTENT
\end{threetable}
\end{document}
这里的构造@{...}
并不特定于任何这些包,它是适用于基本 LaTeX 语法tabular
及其所有扩展,它指定列间材料。