eqn 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  1. .TH EQN 1
  2. .EQ
  3. delim $$
  4. .EN
  5. .SH NAME
  6. eqn \- typeset mathematics
  7. .SH SYNOPSIS
  8. .B eqn
  9. [
  10. .I option ...
  11. ]
  12. [
  13. .I file ...
  14. ]
  15. .SH DESCRIPTION
  16. .I Eqn
  17. is a
  18. .IR troff (1)
  19. preprocessor
  20. for typesetting mathematics
  21. on a typesetter.
  22. Usage is almost always
  23. .IP
  24. .L
  25. eqn file ... | troff
  26. .PP
  27. If no files are specified,
  28. .I eqn
  29. reads from the standard input.
  30. .I Eqn
  31. prepares output for the typesetter
  32. named in the
  33. .BI -T dest
  34. option (default
  35. .BR -Tutf ;
  36. see
  37. .IR troff (1)).
  38. When run with other preprocessor filters,
  39. .I eqn
  40. usually comes last.
  41. .PP
  42. A line beginning with
  43. .B .EQ
  44. marks the start of an equation;
  45. the end of an equation
  46. is marked by a line beginning with
  47. .BR .EN .
  48. Neither of these lines is altered,
  49. so they may be defined in macro packages
  50. to get
  51. centering, numbering, etc.
  52. It is also possible to set two characters
  53. as `delimiters';
  54. text between delimiters is also
  55. .I eqn
  56. input.
  57. Delimiters may be set to characters
  58. .I x
  59. and
  60. .I y
  61. with the option
  62. .BI -d xy
  63. or (more commonly) with
  64. .B delim
  65. .I xy
  66. between
  67. .B .EQ
  68. and
  69. .BR .EN .
  70. Left and right delimiters may be identical.
  71. (They are customarily taken to be
  72. $font L "$$" )$.
  73. Delimiters are turned off by
  74. .LR "delim off" .
  75. All text that is neither between delimiters nor between
  76. .B .EQ
  77. and
  78. .B .EN
  79. is passed through untouched.
  80. .PP
  81. Tokens within
  82. .I eqn
  83. are separated by
  84. spaces, tabs, newlines, braces, double quotes,
  85. tildes or circumflexes.
  86. Braces {} are used for grouping;
  87. generally speaking,
  88. anywhere a single character like
  89. .L x
  90. could appear, a complicated construction
  91. enclosed in braces may be used instead.
  92. Tilde
  93. .L ~
  94. represents a full space in the output,
  95. circumflex
  96. .L ^
  97. half as much.
  98. .PP
  99. .vs 13p
  100. Subscripts and superscripts are produced with the keywords
  101. .B sub
  102. and
  103. .BR sup .
  104. Thus
  105. .L "x sub i"
  106. makes
  107. $x sub i$,
  108. .L "a sub i sup 2"
  109. produces
  110. $a sub i sup 2$,
  111. and
  112. .L "e sup {x sup 2 + y sup 2}"
  113. gives
  114. $e sup {x sup 2 + y sup 2}$.
  115. .PP
  116. .B Over
  117. makes fractions:
  118. .L "a over b"
  119. yields $a over b$.
  120. .PP
  121. .B Sqrt
  122. produces square roots:
  123. .L "1 over sqrt {ax sup 2 +bx+c}"
  124. results in
  125. $1 over sqrt {ax sup 2 +bx+c}$ .
  126. .PP
  127. The keywords
  128. .B from
  129. and
  130. .B to
  131. introduce lower and upper
  132. limits on arbitrary things:
  133. $lim from {n -> inf} sum from 0 to n x sub i$
  134. is made with
  135. .LR "lim from {n -> inf} sum from 0 to n x sub i" .
  136. .PP
  137. Left and right brackets, braces, etc., of the right height are made with
  138. .B left
  139. and
  140. .BR right :
  141. .L "left [ x sup 2 + y sup 2 over alpha right ] ~=~1"
  142. produces
  143. $left [ x sup 2 + y sup 2 over alpha right ] ~=~1$.
  144. The
  145. .B right
  146. clause is optional.
  147. Legal characters after
  148. .B left
  149. and
  150. .B right
  151. are braces, brackets, bars,
  152. .B c
  153. and
  154. .B f
  155. for ceiling and floor,
  156. and
  157. .B
  158. ""
  159. for nothing at all (useful for a right-side-only bracket).
  160. .PP
  161. Vertical piles of things are made with
  162. .BR pile ,
  163. .BR lpile ,
  164. .BR cpile ,
  165. and
  166. .BR rpile :
  167. .L "pile {a above b above c}"
  168. produces
  169. $pile {a above b above c}$.
  170. There can be an arbitrary number of elements in a pile.
  171. .B lpile
  172. left-justifies,
  173. .B pile
  174. and
  175. .B cpile
  176. center, with different vertical spacing,
  177. and
  178. .B rpile
  179. right justifies.
  180. .PP
  181. Matrices are made with
  182. .BR matrix :
  183. .L "matrix { lcol { x sub i above y sub 2 } ccol { 1 above 2 } }"
  184. produces
  185. $matrix { lcol { x sub i above y sub 2 } ccol { 1 above 2 } }$.
  186. In addition, there is
  187. .B rcol
  188. for a right-justified column.
  189. .PP
  190. .vs 12p
  191. Diacritical marks are made with
  192. .BR prime ,
  193. .BR dot ,
  194. .BR dotdot ,
  195. .BR hat ,
  196. .BR tilde ,
  197. .BR bar ,
  198. .BR under ,
  199. .BR vec ,
  200. .BR dyad ,
  201. and
  202. .BR under :
  203. .L "x sub 0 sup prime = f(t) bar + g(t) under"
  204. is
  205. $x sub 0 sup prime = f(t) bar + g(t) under$,
  206. and
  207. .L "x vec = y dyad"
  208. is
  209. $x vec = y dyad$.
  210. .PP
  211. Sizes and fonts can be changed with prefix operators
  212. .B size
  213. .IR n ,
  214. .B size
  215. .BI ± n \f1,
  216. .BR fat ,
  217. .BR roman ,
  218. .BR italic ,
  219. .BR bold ,
  220. or
  221. .BR font
  222. .IR n .
  223. Size and fonts can be changed globally in a document by
  224. .B gsize
  225. .I n
  226. and
  227. .B gfont
  228. .IR n ,
  229. or by the command-line arguments
  230. .BI -s n
  231. and
  232. .BI -f n\f1.
  233. .PP
  234. Normally subscripts and superscripts are reduced by
  235. 3 point sizes from the previous size;
  236. this may be changed by the command-line argument
  237. .BI -p n\f1.
  238. .PP
  239. Successive display arguments can be lined up.
  240. Place
  241. .B mark
  242. before the desired lineup point in the first equation;
  243. place
  244. .B lineup
  245. at the place that is to line up vertically in subsequent equations.
  246. .PP
  247. Shorthands may be defined
  248. or existing keywords redefined with
  249. .BR define :
  250. .L define
  251. .I thing
  252. .L %
  253. .I replacement
  254. .L %
  255. defines a new token called
  256. .I thing
  257. which will be replaced by
  258. .I replacement
  259. whenever it appears thereafter.
  260. The
  261. .L %
  262. may be any character that does not occur in
  263. .LR replacement .
  264. .PP
  265. Keywords like
  266. .L sum
  267. .EQ
  268. ( sum ),
  269. .EN
  270. .L int
  271. .EQ
  272. ( int ),
  273. .EN
  274. .L inf
  275. .EQ
  276. ( inf ),
  277. .EN
  278. and shorthands like
  279. .L >=
  280. .EQ
  281. (>=),
  282. .EN
  283. .L ->
  284. .EQ
  285. (->),
  286. .EN
  287. and
  288. .L !=
  289. .EQ
  290. ( != )
  291. .EN
  292. are recognized.
  293. Greek letters are spelled out in the desired case, as in
  294. .L alpha
  295. or
  296. .LR GAMMA .
  297. Mathematical words like
  298. .LR sin ,
  299. .LR cos ,
  300. .L log
  301. are made Roman automatically.
  302. .IR Troff (1)
  303. four-character escapes like
  304. .L \e(lh
  305. (\(lh) can be used anywhere.
  306. Strings enclosed in double quotes " "
  307. are passed through untouched;
  308. this permits keywords to be entered as text,
  309. and can be used to communicate
  310. with
  311. .I troff
  312. when all else fails.
  313. .SH FILES
  314. .TF /sys/lib/troff/font/devutf
  315. .TP
  316. .B /sys/lib/troff/font/devutf
  317. font descriptions for PostScript
  318. .SH SOURCE
  319. .B /sys/src/cmd/eqn
  320. .SH "SEE ALSO"
  321. .IR troff (1),
  322. .IR tbl (1)
  323. .br
  324. J. F. Ossanna and B. W. Kernighan,
  325. ``Troff User's Manual''.
  326. .br
  327. B. W. Kernighan and L. L. Cherry,
  328. ``Typesetting Mathematics\(emUser's Guide'',
  329. .I
  330. Unix Research System Programmer's Manual,
  331. Tenth Edition, Volume 2.
  332. .SH BUGS
  333. To embolden digits, parens, etc.,
  334. it is necessary to quote them,
  335. as in
  336. .LR bold\ "12.3" .
  337. .EQ
  338. delim off
  339. .EN