案例选择函数可以像\prg_case_int
或一样\prg_case_str
嵌套吗?如果可以,我将提供一些我观察到的嵌套非常奇怪的结果的示例。
修订:
interface3
我省略了一些字符串,弄乱了文档中建议的语法<code case>
。我的实验的修订代码现在可以正常工作,如下所示:
%document name: LaTeX3_interface3.tex
%RN 15/3/2012
% OBJECTIVE: Nesting case-selecting functions prg_case_str or prg_case_int.
% REFERENCE: The LaTeX3 Intefaces, 8 Feb 2012 (interface3.pdf), page 38ff.
% COMMENTS:
% (1) on the first attempt failed to define all of the <code case> strings and the whole
% thing turned pear shaped
% (2) the printed messages in the result are not properly formatted but that's due
% to my inexperience in LaTeX2 and needs to be addressed seperately.
%=====================================================================================
\documentclass{article}
%\usepackage{expl3}
\usepackage{amsmath,xparse}
\ExplSyntaxOn
\NewDocumentCommand{\myCommand}{ m m m }
{
\prg_case_str:nnn { #1 }
{
{1a}
{
\prg_case_str:nnn { #2 }
{
{2A} %{case 1a:2A\\}
{
\prg_case_str:nnn { #3 }
{
{3\alpha} {case 1a:2A:3\alpha\\}
{3\beta} {case 1a:2A:3\beta\\}
{3\gamma} {case 1a:2A:3\gamma\\}
}
{None of 1a:2A: 3\alpha, 3\beta, 3\gamma \\}
}
{2B} %{case 1a:2B\\}
{
\prg_case_str:nnn { #3 }
{
{3\alpha} {case 1a:2B:3\alpha\\}
{3\beta} {case 1a:2B:3\beta\\}
{3\gamma} {case 1a:2B:3\gamma\\}
}
{None of 1a:2B: 3\alpha, 3\beta, or 3\gamma\\}
}
{2C} %{case 1a:2C\\}
{
\prg_case_str:nnn { #3 }
{
{3\alpha} {case 1a:2C:3\alpha\\}
{3\beta} {case 1a:2C:3\beta\\}
{3\gamma} {case 1a:2C:3\gamma\\}
}
{None of 1a:2C: 3\alpha, 3\beta, 3\gamma\\}
}
}
{None of 1a: 2A, 2B, 2C\\}
}
{1b}
{
\prg_case_str:nnn { #2 }
{
{2A} {case 1b:2A\\}
{2B} {case 1b:2B\\}
{2C} {case 1b:2C\\}
}
{None of 1b: 2A, 2B, 2C\\}
}
{1c}
{
\prg_case_str:nnn { #2 }
{
{2A} {case 1c:2A\\}
{2B} {case 1c:2B\\}
{2C} {case 1c:2C\\}
}
{None of 1c: 2A, 2B, 2C\\}
}
}
{None of 1a, 1b, 1c\\}
}
%etc. etc.
\ExplSyntaxOff
\begin{document}
$\myCommand{1a}{2A}{3\alpha}$
$\myCommand{1a}{2B}{3\beta}$
$\myCommand{1a}{2C}{3\gamma}$
$\myCommand{1b}{2A}{3gamma}$
$\myCommand{1b}{2B}{3gamma}$
$\myCommand{1b}{2C}{3gamma}$
$\myCommand{x}{2A}{3gamma}$
$\myCommand{1a}{y}{3gamma}$
$\myCommand{1a}{2C}{3gamma}$
$\myCommand{1b}{2A}{3gamma}$
$\myCommand{z}{2B}{3gamma}$
$\myCommand{1b}{2C}{3gamma}$
\end{document}
如果我知道如何导入生成的 .pdf 文档我就会这么做。
抱歉,我又开始白费力气了。我唯一的借口是,在没有自动编辑工具的情况下,LaTeX 语法很难正确使用,而自动编辑工具至少可以生成正确的缩进。也许这样的 LaTeX3 编辑工具已经可用,如果有的话,我很想听听。