环境定义中的代码在从环境命令中使用时会中断,但直接使用时可以正常工作

环境定义中的代码在从环境命令中使用时会中断,但直接使用时可以正常工作

我正在尝试为自己构建一些不错的语义环境来编写文档,这样我就可以将格式问题与内容等问题分开。不幸的是,我遇到了一个问题,定义环境会中断,而直接使用环境定义的内容则不会中断。

具体来说,有以下几种情况。

\documentclass{article}

\begin{document}

\newenvironment{skills}
{
    \newenvironment{skill}[1]{##1 & \begin{itemize}}{\end{itemize} \\}
    \begin{tabular}{c p{0.8\textwidth}}
}
{
    \end{tabular}
    \let\skill\undefined
}

\begin{skills}
    \begin{skill}{Linux}
        \item Use Arch Linux as my daily driver to complete everyday computing tasks
    \end{skill}
\end{skills}

\end{document}

给出的错误是:

! Extra }, or forgotten \endgroup.
<template> \unskip \hfil }
                          \hskip \tabcolsep \endtemplate 
l.16     \begin{skill}{Linux}

但以下有效。

\documentclass{article}

\begin{document}

\newenvironment{skills}
{                                                                                
    \begin{tabular}{c p{0.8\textwidth}}
}
{
    \end{tabular}
}

\begin{skills}
    Linux & \begin{itemize}
        \item Use Arch Linux as my daily driver to complete everyday computing tasks
    \end{itemize} \\
\end{skills}

\end{document}

我正在使用 xelatex。

$ xelatex --version
XeTeX 3.141592653-2.6-0.999994 (TeX Live 2022/Arch Linux)
kpathsea version 6.3.4
Copyright 2022 SIL International, Jonathan Kew and Khaled Hosny.
There is NO warranty.  Redistribution of this software is
covered by the terms of both the XeTeX copyright and
the Lesser GNU General Public License.
For more information about these matters, see the file
named COPYING and the XeTeX source.
Primary author of XeTeX: Jonathan Kew.
Compiled with ICU version 71.1; using 71.1
Compiled with zlib version 1.2.12; using 1.2.12
Compiled with FreeType2 version 2.12.0; using 2.12.1
Compiled with Graphite2 version 1.3.14; using 1.3.14
Compiled with HarfBuzz version 4.2.0; using 4.3.0
Compiled with libpng version 1.6.37; using 1.6.37
Compiled with pplib version v2.05 less toxic i hope
Compiled with fontconfig version 2.14.0; using 2.14.0

是什么赋予了?

相关内容