--- ./om.tmac.orig	2005-01-21 05:44:27.000000000 +0300
+++ ./om.tmac	2005-03-19 16:02:29.000000000 +0300
@@ -4590,6 +4528,7 @@
 .       if !r#EN_NUMBERS_ALIGN_RIGHT \{ .ENDNOTE_NUMBERS_ALIGN_RIGHT 2  \}
 .    \}
 .    if !d$TOC_HEADER_STRING         \{ .TOC_HEADER_STRING "Contents"  \}
+.    if !d$REF_HEADER_STRING         \{ .REF_HEADER_STRING "References" \}
 .    if !d$TOC_HEADER_QUAD           \{ .TOC_HEADER_QUAD LEFT          \}
 .    if !d$TOC_PN_STYLE              \{ .TOC_PAGENUM_STYLE roman       \}
 .    if !r#TOC_PN_PADDING            \{ .TOC_PADDING   3               \}
@@ -13207,3 +13146,193 @@
 .    br
 .    sp -1v
 .END
+.\" ****************************
+.\" ******** module ref ********
+.\" ****************************
+.\" Refer support.
+\#
+\# - for References "doc header" (i.e. "References")
+\#
+\# REF HEADER STRING
+\# -----------------
+\# *Argument:
+\#   <string for "doc header" of first references page>
+\# *Function:
+\#   Creates or modifies string $REF_HEADER_STRING
+\# *Notes:
+\#   Default is "References".
+\#
+.MAC REF_HEADER_STRING END
+.    ds $REF_HEADER_STRING \\$1
+.END
+.\" MS footnotes emulation.
+.MAC FS END
+.	nr #SAVED_FN_MARKER_STYLE \\n[#FN_MARKER_STYLE]
+.	nr #SAVED_FN_NUMBER \\n[#FN_NUMBER]
+.	nr #FN_MARKER_STYLE 2
+.	nr #FN_NUMBER	[F
+.	FOOTNOTE
+.END
+.MAC FE END
+.	FOOTNOTE OFF
+.	nr #FN_MARKER_STYLE	\\n[#SAVED_FN_MARKER_STYLE]
+.	nr #FN_NUMBER		\\n[#SAVED_FN_NUMBER]
+.END
+.\" End of ms emulation
+.\" Refer support.
+.de ]-
+.rm [A [B [C [D [E [G [I [J [N [O [P [Q [R [S [T [V
+.rm ref*string
+..
+.\" Other
+.ds ref*spec!0 Q A T1 S V N P I C D O
+.\" Journal article
+.ds ref*spec!1 Q A T2 J S V N P I C D O
+.\" Book
+.ds ref*spec!2 Q A T1 S V P I C D O
+.\" Article within book
+.ds ref*spec!3 Q A T2 B E S V P I C D O
+.\" Tech report
+.ds ref*spec!4 Q A T2 R G P I C D O
+.\" ][ type
+.de ][
+.if r [T \{\
+.	als [T1 [T
+.	als [T2 [T
+.\}
+.ie d ref*spec!\\$1 .ref*build \\*[ref*spec!\\$1]
+.el \{\
+.	@error unknown reference type `\\$1'
+.	ref*build \\*[ref*spec!0]
+.\}
+.ref*print
+.rm ref*string
+.rm [F [T1 [T2
+..
+.\" start of reference number
+.ds [. \\*[par@sup-start]
+.\" end of reference number
+.ds .] \\*[par@sup-end]
+.\" period before reference
+.ds <. .
+.\" period after reference
+.ds >. \" empty
+.\" comma before reference
+.ds <, ,
+.\" comma after reference
+.ds >, \" empty
+.\" start collected references
+.de ]<
+.als ref*print ref*end-print
+.HEAD "\\*[$REF_HEADER_STRING]"
+.LIST DIGIT
+.par@reset
+..
+.\" end collected references
+.de ]>
+.LIST OFF
+.par@finish
+.als ref*print ref*normal-print
+..
+.de ref*normal-print
+.ie d [F .FS "\\*([.\\*([F\\*(.]"
+.el .FS \&
+\\*[ref*string]
+.FE
+..
+.de ref*end-print
+.ie d [F \{\
+.	nr #SAVED_ENUMERATOR	\\n[#ENUMERATOR]\\n[#DEPTH]
+.	nr #ENUMERATOR\\n[#DEPTH] [F 
+.	ITEM 
+.	nr #ENUMERATOR\\n[#DEPTH]	\\n[#SAVED_ENUMERATOR]
+.	PP
+\\*[ref*string]
+.\}
+.el \{\
+\" Emulate ms .XP. I wonder if it works.
+.	IL 1P
+.	HI 1P
+\\*[ref*string]
+.	IQ
+.\}
+..
+.als ref*print ref*normal-print
+.de ref*build
+.rm ref*string ref*post-punct
+.nr ref*suppress-period 1
+.while \\n[.$] \{\
+.	if d [\\$1 \{\
+.		ie d ref*add-\\$1 .ref*add-\\$1
+.		el .ref*add-dflt \\$1
+.	\}
+.	shift
+.\}
+.\" now add a final period
+.ie d ref*string \{\
+.	if !\\n[ref*suppress-period] .as ref*string .
+.	if d ref*post-punct \{\
+.		as ref*string "\\*[ref*post-punct]
+.		rm ref*post-punct
+.	\}
+.\}
+.el .ds ref*string
+..
+.de ref*add-T1
+.ref*field T , "\fI" "" "\fP"
+.if r [T .nr ref*suppress-period \\n([T
+..
+.de ref*add-T2
+.ref*field T , "\\*Q" "" "\\*U"
+.if r [T .nr ref*suppress-period \\n([T
+..
+.de ref*add-P
+.ie \\n([P>0 .ref*field P , "pp. "
+.el .ref*field P , "p. "
+..
+.de ref*add-J
+.ref*field J , \fI "" \fP
+..
+.de ref*add-D
+.ref*field D "" ( )
+..
+.de ref*add-E
+.ref*field E , "ed. "
+..
+.de ref*add-G
+.ref*field G "" ( )
+..
+.de ref*add-B
+.ref*field B "" "in \fI" "" \fP
+..
+.de ref*add-O
+.ref*field O .
+.ie r [O .nr ref*suppress-period \\n([O
+.el .nr ref*suppress-period 1
+..
+.de ref*add-A
+.ref*field A ,
+.if r [A .nr ref*suppress-period \\n([A
+..
+.de ref*add-dflt
+.ref*field \\$1 ,
+..
+.\" First argument is the field letter.
+.\" Second argument is the punctuation character to use to separate this field
+.\" from the previous field.
+.\" Third argument is a string with which to prefix this field.
+.\" Fourth argument is a string with which to postfix this field.
+.\" Fifth argument is a string to add after the punctuation character supplied
+.\" by the next field.
+.de ref*field
+.if d ref*string \{\
+.	ie d ref*post-punct \{\
+.		as ref*string "\\$2\\*[ref*post-punct] \"
+.		rm ref*post-punct
+.	\}
+.	el .as ref*string "\\$2 \"
+.\}
+.as ref*string "\\$3\\*([\\$1\\$4
+.if \\n[.$]>4 .ds ref*post-punct "\\$5
+.nr ref*suppress-period 0
+..
