summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/ntheorem-vn/src/endmarks.tex
blob: e85f82cd1f520419722c499bc0186a18aa44d889 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
%% \section{The End Mark Algorithm}
\section{Thuật toán đặt dấu kết thúc}


%%  \subsection{The Idea}
\subsection{Ý tưởng}


%%  The handling of endmarks with |thmmarks.sty| is based on the same
%%  two-pass principle as the handling of labels: the necessary information
%%  about endmarks is contained in the |.aux| file.
Thuật toán xử lý dấu kết thúc của |ntheorem| được xây dựng cùng ý tưởng
với việc xử lý các nhãn của \LaTeX{}: các thông tin cần thiết về dấu kết thúc
sẽ được để trong tập tin |.aux|.

\medskip
%%  With |thmmarks.sty|, \TeX\ is always aware whether it is in
%%  some theorem-like environment.
%%  There, potential positions for endmarks can be
Với gói |thmmarks|, \TeX{} luôn cẩn thận quan sát xem liệu nó có đang
ở trong một môi trường |THM| hay không. Vị trí tương lai của
dấu kết thúc có thể là
 \begin{enumerate}
  \item\label{elist:1} %at the end of simple text lines in open text, 
  	cuối dòng văn bản đơn giản,
  \item\label{elist:2}% at the end of displaymaths, 
  	cuối một biểu thức toán,
  \item\label{elist:3} %at the end of equations or equationarrays, or 
  	cuối môi trường phương trình hoặc dãy phương trình,
  \item\label{elist:4} %at the end of text lines at the end of lists (or, more general, 
%%    |trivlists|, such as |verbatim| or |center|).
	hoặc cuối dòng cuối của một danh sách (tổng quát hơn, của danh sách |\trivlist|,
	như |verbatim| hoặc |center|).
 \end{enumerate}

%%  The problem is, that in the cases (\ref{elist:2})--(\ref{elist:4}), the endmarks has to
%%  be placed in a box which is already shipped out, when
%%  |\end{...}| is processed.
%%  Thus, in those situations, \TeX\ needs to know from the |.aux|
%%  file, whether is has to put an endmark.
	Vấn đề là, trong các trường hợp (\ref{elist:2})--(\ref{elist:4}),
	dấu kết thúc phải được đặt trong một |box| đã được thể hiện xong (|shipped out|),
	khi gặp kết thúc môi trường |THM| bởi |\end{...}|.
	Vì vậy, ở các trường hợp này, \TeX{} cần đọc thông tin từ tập tin từ |.aux|
	xem, liệu nó có phải đặt dấu kết thúc hay không.

%%  When \TeX\ is in a theorem-like environment and comes to one of 
%%  the points mentioned in (\ref{elist:2})--(\ref{elist:4}),
%%  and the |.aux| file says that there is an endmark, then
%%  it is put there.
\medskip
	Khi \TeX{} đang  ở trong môi trường |THM| và gặp một trong
	các thời điểm nói ở (\ref{elist:2})--(\ref{elist:4}),
	đồng thời tập tin |.aux| cho biết rằng đến lúc đặt dấu kết thúc,
	\TeX{} sẽ làm công việc đó.
	
%%  Anyway, it maintains a counter of the potential positions of an end 
%%  mark in the current theorem-like environment.
	
 When it comes to an |\end{theorem}|, it looks if it is in
 situation (\ref{elist:1}) (then the endmark is simply put at the end of the
 current line).
 Otherwise, the last horizontal box is already shipped out
 (thus it contains a situation (\ref{elist:2})--(\ref{elist:4})) and the endmark must be
 set in it.
 In this case, a note is written in the |.aux| file, where the
 endmark actually has to be set (ie, at the latest potential point for
 setting an endmark inside the theorem).

 \subsection{The Realization}

 Let \env\ be a theorem-like environment. Then, additional to
 the counter \env, \TeX\ maintains two counters
 |curr|\env|ctr| and |end|\env|ctr|.
 In the $i$th environment of type \env, |curr|\env|ctr|$=i$
 (the \LaTeX\ counter \env\ cannot be used since a)
 environments can use the counter of other environments, and b) 
 often  counters are reinitialized inside a document).
 |end|\env|ctr| counts the potential situations for
 putting an endmark inside an environment.
 It is set to 1 when starting an environment. Each time, when
 a situation (\ref{elist:2})--(\ref{elist:4}) is reached, the command
 \begin{quote}
   |\mark|$<$|\roman{curr|env|ctr}|$>$\env
               $<$|\roman{end|\env|ctr}|$>$
 \end{quote}
 is called
 ($<$|\roman{curr|\env|ctr}|$>$\env
  $<$|\roman{end|\env|ctr}|$>$
  uniquely identifies all situations (\ref{elist:2})--(\ref{elist:4}) in a document).

 If at this position an endmark has to be set, 
 \begin{quote}
  |\mark|$<$|\roman{curr|\env|ctr}|$>$\env
              $<$|\roman{end|\env|ctr}|$>$ 
 \end{quote}
 is defined in the |.aux| file to be |\end|\env|Symbol|,
 otherwise it is undefined and simply ignored.

 When \TeX\ comes to an |\end{|\env|}|, it looks if it is in
 situation (\ref{elist:1}). If so, the endmark is simply put at the end of the
 current line.
 Otherwise,
 \begin{quote}
   |\def\mark|$<$|\roman{curr|env|ctr}|$>$\env|%|\\
      $<$|\roman{end|\env|ctr}|$>$|{|\env|Symbol}| 
 \end{quote}
 is written to the |.aux| file for setting the endmark
 at the latest potential position inside the theorem in the next run.

 \begin{Theorem}[Correctness]
  \begin{enumerate}
 \item For a |.tex| file, which does not contain nested theorem-like
 environments of the same type, in the above situation, the following 
 holds:
 When compiling, at the $i$th situation in the $j$th environment of type
 \env, |mark|$\;j\,$\env$\;i$ is handled. 

 For |.tex| files which contain nested theorem-like environments of
 the same type, |mark|$\;k\,$\env$\;l$ is handled, where
 $k$ is the number of the latest environment of type \env\ which
 has been called at this moment, and $l$ is the number of situations
 (\ref{elist:2})--(\ref{elist:4}) which have occurred in
 environments of type \env\ since
 the the $k$th |\begin{|\env|}|. 

 \item When finishing an environment, either an endmark is set directly
 (when in a text line) or an order to put the end symbol at the latest
 potential position is written to the |.aux| file.
 \end{enumerate}
 \end{Theorem}

 \begin{Theorem}[Completeness]
 The handling of endmarks is complete wrt.\ plain text, |displaymath|,
 |equation|,\\ |eqnarray|, |eqnarray*|, and all environments
 ended by |endtrivlist|, including |center| and
 |verbatim|.
 \end{Theorem}

 So, where can be bugs ? 
 \begin{itemize}
  \item in the plain \TeX\ handling of endmarks, 
  \item in some special situations which have not been tested yet, 
  \item in some special environments which have not been tested yet. 
  \item in the |amsmath| environments. We seldom use them, so we do not
   know their pitfalls, and we ran only general test cases.
 \end{itemize}
 
\endinput