在下面的代码中,该行\AfterGroup*
(来自etextools
包)导致pdfLatex
编译器“阻塞”,即它只产生这个输出并且该过程永远卡住,消耗 13% 的 CPU:
This is pdfTeX, Version 3.1415926-2.5-1.40.14 (MiKTeX 2.9)
entering extended mode
(C:/Users/arul/AppData/Local/Temp/TE_temp_preview5132.tex
LaTeX2e <2011/06/27>
Babel <v3.8m> and hyphenation patterns for english, afrikaans, ancientgreek, ar
abic, armenian, assamese, basque, bengali, bokmal, bulgarian, catalan, coptic,
croatian, czech, danish, dutch, esperanto, estonian, farsi, finnish, french, ga
lician, german, german-x-2013-05-26, greek, gujarati, hindi, hungarian, iceland
ic, indonesian, interlingua, irish, italian, kannada, kurmanji, latin, latvian,
lithuanian, malayalam, marathi, mongolian, mongolianlmc, monogreek, ngerman, n
german-x-2013-05-26, nynorsk, oriya, panjabi, pinyin, polish, portuguese, roman
ian, russian, sanskrit, serbian, slovak, slovenian, spanish, swedish, swissgerm
an, tamil, telugu, turkish, turkmen, ukenglish, ukrainian, uppersorbian, usengl
ishmax, welsh, loaded.
(C:\Users\arul\AppData\Local\Temp\TE_temp_preview5132.aux)
ABD: EveryShipout initializing macros
("C:\Program Files (x86)\MiKTeX 2.9\tex\context\base\supp-pdf.mkii"
[Loading MPS to PDF converter (version 2006.09.02).]
对于代码,我希望能够通过它们的 id 全局访问对象的不同部分,但由于宏是在一个组内创建的(并且pgfkeys
局限于当前组),所以我需要\pgfkeys
在全局范围内执行命令,从而\AfterGroups*
执行命令(或者我需要 2 \AfterGroups*
,另一个来逃离newenvironment
限制?)
\documentclass{article}%
\usepackage{tikz,amsmath,amssymb,bm,color,etextools}%
\usepackage[margin=0cm,nohead]{geometry}%
\usetikzlibrary{calc}%
%
\begin{document}%
\begin{tikzpicture}%
%
\def\addobjectpart#1#2#3{%
\pgfkeys{/instance/#1/ref name/.initial={a}, /instance/#1/ref color/.initial={b}}%
\pgfkeys{/instance/#1/ref name={#2}, /instance/#1/ref color={#3}}%
}%
%
\newenvironment{myobject}[1] {
\newcommand*{\addpart}[1][]{\object[##1]};%
\def\object[##1]##2;{%
\begingroup%
\def\objid{1}%
\def\name{bla}%
\def\objcolor{black!50}%
\AfterGroup*{\addobjectpart{\expandonce{\objid}}{\expandonce{\name}}{\expandonce{\objcolor}}}% <! HELL BREAKS LOOSE
\endgroup%
};%
}{};%
\begin{myobject}[BLAH]%
\addpart[]{text ehm};%
\end{myobject}%
\end{tikzpicture}%
\end{document}%
编辑:中止进程后完成日志文件:http://pastebin.com/BuwTt305
答案1
好的,这是最终有效的代码,关键部分是\noexpand
内部内容objmacro
:
\xdef\objmacro{\noexpand\addobject {\objname}{\objcolor}}
\aftergroup\objmacro
我的问题是,一开始我Pgf/Tikz
对它所基于的底层技术一无所知。我认为 TeX 太棒了!用于排版计算机指令和伪代码的软件包很快就会登陆 CTAN。
\begin{instruction}{85. LDR (register)}%
%
\addpart[bits=5,register] {Rd};%
\addpart[bits=5,register] {Rn};%
\addpart[bits=2] {0, 1};%
\addpart[bits=1,opcode] {S};%
\addpart[name=opc1,opcode,bits=3,name overlay=red!30] {option};%
\addpart[bits=5,register] {Rm};%
\addpart[bits=9] {1, 1, 0, 0, 0, 0, 1, 1, 1};%
\addpart[name=size,bits=2,name overlay=orange!50] {x,1};%
%
\newvariant[32-bit, node={size}, equals]{10};%
%
\newmnemonics[operand={<Wt>}, comma, open bracket, optional={<Xn|SP>}, comma, optional={<R>}, optional={<m>},
open curly, variant={<extend>}, open curly, comma, inner variant={<amount>},
close curly, close curly, close bracket]{LDR};
%
\newvariant[64-bit, node={size}, equals]{11};%
%
\newmnemonics[operand={<Xt>}, comma, open bracket, optional={<Xn|SP>}, comma, optional={<R>}, optional={<m>},
open curly, variant={<extend>}, open curly, comma, inner variant={<amount>},
close curly, close curly, close bracket]{LDR};
%
%
\end{instruction}%