LaTeX doc 包 keyval 包的文档键

LaTeX doc 包 keyval 包的文档键

我正在尝试记录一个使用 keyval 进行键/值参数解析的包。

我希望以记录宏和环境的相同方式记录某些命令的键/值选项。我知道我可以使用环境,但我不确定会有什么副作用。

以下是我的示例:

%\begin{environment}{x}
% x represents the x value
%    \begin{macrocode}
\define@key{mymacro@x}{x}{\def\mymacro@x{#1}}
%    \end{macrocode}
%\end{environment}

虽然这看起来不错,但它最终出现在索引的环境部分下,我不确定是否会有其他副作用。

有没有办法排版类似文档的实体,但控制它在索引中的位置,而不是让它出现在环境下?

答案1

以下是基于 doc 包文档的一个小解决方案。我不确定它的效果如何,因为我不完全理解从其文档中复制的所有内容,但这是我正在使用的:

% \makeatletter
% \def\DescribeKey{\leavevmode\@bsphack\begingroup\MakePrivateLetters\Describe@Key}
% \def\Describe@Key#1{\endgroup\marginpar{\raggedleft\PrintDescribeKey{#1}}\SpecialKeyIndex{#1}\@esphack\ignorespaces}
% \def\PrintDescribeKey#1{\strut \MacroFont #1\ }
% \def\SpecialKeyIndex#1{\@bsphack
%     \index{#1\actualchar{\protect\ttfamily#1}(key)\encapchar usage}^^A
%     \index{keys:\levelchar#1\actualchar{\protect\ttfamily#1}\encapchar usage}\@esphack}
% \def\keyvalue{\begingroup\catcode`\\12\MakePrivateLetters\m@cro@key@}
% \long\def\m@cro@key@#1{\endgroup\topsep\MacroTopsep\trivlist
%     \edef\saved@macroname{\string#1}^^A
%     \let\saved@indexname\saved@macroname
%     \def\makelabel##1{\llap{##1}}^^A
%     \if@inlabel
%         \let\@tempa\@empty \count@\macro@cnt
%         \loop \ifnum\count@>\z@
%             \edef\@tempa{\@tempa\hbox{\strut}}\advance\count@\m@ne \repeat
%         \edef\makelabel##1{\llap{\vtop to\baselineskip{\@tempa\hbox{##1}\vss}}}^^A
%         \advance \macro@cnt \@ne
%     \else \macro@cnt\@ne \fi
%     \edef\@tempa{\noexpand\item[^^A
%         \noexpand\PrintKeyName{\string#1}]}^^A
%     \@tempa
%     \global\advance\c@CodelineNo\@ne
%     \SpecialMainKeyIndex{#1}\nobreak
%     \global\advance\c@CodelineNo\m@ne
%     \ignorespaces}
% \let\endkeyvalue\endmacro
% \def\PrintKeyName#1{\strut \MacroFont #1\ }
% \def\SpecialMainKeyIndex#1{\@bsphack^^A
%     \special@index{#1\actualchar{\string\ttfamily\space#1} (key) \encapchar main}^^A
%     \special@index{keys:\levelchar#1\actualchar{\string\ttfamily\space#1}\encapchar main}\@esphack}
% \makeatother

应该允许\DescribeKey\begin{keyvalue}{...}按照宏和环境。

相关内容