我对显示数学模式有问题$$...$$
,\[...\]
请参见显示数学模式和“中心”环境。所以,我想找到显示数学模式的定义$$...$$
以便清楚地理解它。但是,我找不到显示数学模式的定义在哪里。
请告诉我,显示数学模式的定义在哪里$$...$$
?
答案1
$$
在 tex 的源代码中定义,它不是 latex 定义的环境。catcode 3 中的任意两个字符开始显示数学。
源代码是用 web(pascal)编写的
tex.web 可从 ctan 获取
https://ctan.org/tex-archive/systems/knuth/dist/tex
$
这是扫描或$$
输入内联或显示数学的部分。
@ We get into math mode from horizontal mode when a `\.\$' (i.e., a
|math_shift| character) is scanned. We must check to see whether this
`\.\$' is immediately followed by another, in case display math mode is
called for.
@<Cases of |main_control| that build...@>=
hmode+math_shift:init_math;
@ @<Declare act...@>=
procedure init_math;
label reswitch,found,not_found,done;
var w:scaled; {new or partial |pre_display_size|}
@!l:scaled; {new |display_width|}
@!s:scaled; {new |display_indent|}
@!p:pointer; {current node when calculating |pre_display_size|}
@!q:pointer; {glue specification when calculating |pre_display_size|}
@!f:internal_font_number; {font in current |char_node|}
@!n:integer; {scope of paragraph shape specification}
@!v:scaled; {|w| plus possible glue amount}
@!d:scaled; {increment to |v|}
begin get_token; {|get_x_token| would fail on \.{\\ifmmode}\thinspace!}
if (cur_cmd=math_shift)and(mode>0) then @<Go into display math mode@>
else begin back_input; @<Go into ordinary math mode@>;
end;
end;
@ @<Go into ordinary math mode@>=
begin push_math(math_shift_group); eq_word_define(int_base+cur_fam_code,-1);
if every_math<>null then begin_token_list(every_math,every_math_text);
end
@ We get into ordinary math mode from display math mode when `\.{\\eqno}' or
`\.{\\leqno}' appears. In such cases |cur_chr| will be 0 or~1, respectively;
the value of |cur_chr| is placed onto |save_stack| for safe keeping.
@<Cases of |main_control| that build...@>=
mmode+eq_no: if privileged then
if cur_group=math_shift_group then start_eq_no
else off_save;
@ @<Put each...@>=
primitive("eqno",eq_no,0);
@!@:eq_no_}{\.{\\eqno} primitive@>
primitive("leqno",eq_no,1);
@!@:leq_no_}{\.{\\leqno} primitive@>
@ When \TeX\ is in display math mode, |cur_group=math_shift_group|,
so it is not necessary for the |start_eq_no| procedure to test for
this condition.
@<Declare act...@>=
procedure start_eq_no;
begin saved(0):=cur_chr; incr(save_ptr);
@<Go into ordinary math mode@>;
end;
@ @<Cases of |print_cmd_chr|...@>=
eq_no:if chr_code=1 then print_esc("leqno")@+else print_esc("eqno");
@ @<Forbidden...@>=non_math(eq_no),
@ When we enter display math mode, we need to call |line_break| to
process the partial paragraph that has just been interrupted by the
display. Then we can set the proper values of |display_width| and
|display_indent| and |pre_display_size|.
@<Go into display math mode@>=
begin if head=tail then {`\.{\\noindent\$\$}' or `\.{\$\${ }\$\$}'}
begin pop_nest; w:=-max_dimen;
end
else begin line_break(display_widow_penalty);@/
@<Calculate the natural width, |w|, by which the characters of the
final line extend to the right of the reference point,
plus two ems; or set |w:=max_dimen| if the non-blank information
on that line is affected by stretching or shrinking@>;
end;
{now we are in vertical mode, working on the list that will contain the display}
@<Calculate the length, |l|, and the shift amount, |s|, of the display lines@>;
push_math(math_shift_group); mode:=mmode;
eq_word_define(int_base+cur_fam_code,-1);@/
eq_word_define(dimen_base+pre_display_size_code,w);
eq_word_define(dimen_base+display_width_code,l);
eq_word_define(dimen_base+display_indent_code,s);
if every_display<>null then begin_token_list(every_display,every_display_text);
if nest_ptr=1 then build_page;
end