tabulary
当我明确写出表头时,该包在下面的设置中运行良好。但是当我在自定义环境中包装完全相同的命令时,TeX 会在 处停止\par
,并显示以下消息:
! File ended while scanning use of \TY@get@body.
我如何tabulary
在这个环境中使用?
\documentclass{article}
\usepackage{geometry} % need wider textblock for table
\usepackage{parskip} % everything flushleft with line spaces between paragraphs
\usepackage{booktabs} % for \toprule
\usepackage{tabulary}
\newenvironment{schedule}[1]
{\textsc{#1}\par%
\begin{tabulary}{\textwidth}{llLl}
\toprule%
}
{\end{tabulary}\par\medskip}
\begin{document}
% Version 1, commands written out, no problem
\section*{Herr Dr. Professor}
\textsc{Classes}
\begin{tabulary}{\textwidth}{llLl}
\toprule
Mon., Wed. & 9--10:50 a.m. & Introduction to \TeX, \LaTeX, and friends & Knuth Hall 80\\
Tue. & 12--2:50 p.m. & Seminar: Procrastination through Macros & Lamport Auditorium 95\\
\end{tabulary}
% Version 2, wrapped in environment, will not compile
\section*{Herr Dr. Professor}
\begin{schedule}{Classes}
Mon., Wed. & 9--10:50 a.m. & Introduction to \TeX, \LaTeX, and friends & Knuth Hall 80\\
Tue. & 12--2:50 p.m. & Seminar: Procrastination through Macros & Lamport Auditorium 95\\
\end{schedule}
\end{document}
版本 1 本身可按要求进行编译:
答案1
手册tabularx
上说,为了在另一个环境的定义中使用环境,你必须使用“内部”形式\tabularx
和。虽然手册上没有具体说明,但\endtabularx
对也是如此。tabulary
\newenvironment{schedule}[1]
{\textsc{#1}\par
\tabulary{\textwidth}{llLl}
\toprule
}
{\endtabulary\par\medskip}