-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommon.m4
168 lines (124 loc) · 5.41 KB
/
common.m4
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
m4_divert(-1)
m4_changecom()
m4_changequote(`<|', `|>')
m4_define(<|define_blind|>, <|_define_blind(<|$1|>, <|$2|>, <|$|><|#|>, <|$|><|0|>)|>)
m4_define(<|_define_blind|>, <|m4_define(<|$1|>, <|m4_ifelse(<|$3|>, <|0|>, <|<|$4|>|>, <|$2|>)|>)|>)
m4_ifelse(MMSDocType, TeXDoc, <|define_blind(TeX, <|$*|>)define_blind(HTML,)|>, <|define_blind(TeX,)define_blind(HTML, <|$*|>)|>)
define_blind(Comment, <||>)
define_blind(<|NewMMS|>, <|define_blind($1, <|TeX(<|$2|>)HTML(<|$3|>)|>)|>)
NewMMS(em, <|{\em $*}|>, <|<em>$*</em>|>)
NewMMS(sc, <|{\sc $*}|>, <|<sc>$*</sc>|>)
NewMMS(bf, <|{\bf $*}|>, <|<b>$*</b>|>)
Two types of teletype
NewMMS(tt, <|\verb@$*@|>, <|<tt>$*</tt>|>)
NewMMS(Tt, <|{\tt $*}|>, <|<tt>$*</tt>|>)
NewMMS(Chapter, <|\section{$1}<||>m4_ifelse($2,<||>,<||>,<|\label{$2}|>)|>,
<|m4_ifelse($2,<||>,<||>,<|<a name="$2">|>)<h1>$1</h1>m4_ifelse($2,<||>,<||>,<|</a>|>)<p>|>)
NewMMS(Section, <|\subsection{$1}<||>m4_ifelse($2,<||>,<||>,<|\label{$2}|>)|>,
<|m4_ifelse($2,<||>,<||>,<|<a name="$2">|>)<h2>$1</h2>m4_ifelse($2,<||>,<||>,<|</a>|>)<p>|>)
NewMMS(Subsection, <|\subsubsection{$1}<||>m4_ifelse($2,<||>,<||>,<|\label{$2}|>)|>,
<|m4_ifelse($2,<||>,<||>,<|<a name="$2">|>)<h3>$1</h3>m4_ifelse($2,<||>,<||>,<|</a>|>)<p>|>)
NewMMS(Paragraph, <|\paragraph{$1}<||>m4_ifelse($2,<||>,<||>,<|\label{$2}|>)|>,
<|m4_ifelse($2,<||>,<||>,<|<a name="$2">|>)<h6>$1</h6>m4_ifelse($2,<||>,<||>,<|</a>|>)<p>|>)
NewMMS(Block, <|\begin{quote}$*\end{quote}|>,
<|<blockquote><p>$*</blockquote>|>)
Figures take (filename, caption, HTML scaling, TeX scaling). The label associated is the
filename with everything after the dot replaced with "pic". E.g., pants.jpg ==> pantspic.
The HTML scaling is a percentage, like 90; the TeX is a fraction, like .9. Both are
optional; 100%|1.0 is assumed.
NewMMS(Pic, <|\begin{figure}[htb]
\begin{center}
\scalebox{m4_ifelse(<|$4|>, <||>, 1, <|$4|>)}{\includegraphics{$1}}
\caption{$2}
\label{m4_patsubst($1, <|\..*|>, <|pic|>)}
\end{center}
\end{figure}
|>,
<|<a name="m4_patsubst($1, <|\..*|>, <|pic|>)"><img src="$1" alt="$2" width="m4_ifelse(<|$3|>, <||>, 100, <|$3|>)%"></a>|>)
m4_define(<|MMSFnCtr|>, 1)
NewMMS(Footnote,<|\footnote{$1}|>,
<|<a name="fnsrc_<||>MMSFnCtr"><a href="#note_<||>MMSFnCtr"><sup>MMSFnCtr</sup></a></a>
m4_divert(6)
m4_ifelse(MMSFnCtr, 1, <hr width="15%" align="left">)
<a name="note_<||>MMSFnCtr"><a href="#fnsrc_<||>MMSFnCtr">MMSFnCtr</a></a>. $1<br>
m4_divert(0)m4_define(<|MMSFnCtr|>, m4_incr(MMSFnCtr))|>)
TeX(<|define_blind(Items,
<|\begin{itemize}
\setlength{\itemsep}{0pt}
\setlength{\parskip}{0pt}
\setlength{\parsep}{0pt}
m4_patsubst(<|$@|>, <|∙|>, <|\\item |>)\end{itemize}|>
)|>)
HTML version produces a <ul></li> that has to be cut down by sed to <ul>
HTML(<|define_blind(Items,
<|<ul>m4_patsubst(<|$@|>, <|∙|>, <|</li>
<li>|>)
</li></ul>|>
)|>)
NewMMS(Citet, <|\citet{$1}|>,
<|<a href="#$1">$2</a>|>)
NewMMS(Citep, <|\citep<||>m4_ifelse($2,<||>,<||>,<|[$2]|>){$1}|>,
<|(<a href="#$1">$1<||>m4_ifelse($2,<||>,<||>,<|, $2|>)</a>)|>)
NewMMS(Link, <|\link{m4_shift($*)}{$1}|>,
<|<a href="$1">m4_shift($*)</a>|>)
NewMMS(PRef, <|$1 (page \pageref{m4_translit(<|$2|>, '
')})|>, <|<a href="#<||>m4_translit(<|$2|>, '
')">$1</a>|>)
NewMMS(Ref, <|\ref{m4_translit(<|$2|>, '
')}|>, <|<a href="#<||>m4_translit(<|$2|>, '
')">$1</a>|>)
m4_divert(9)
HTML(<|
</P>
</body></html>
|>)
TeX(<|
m4_ifelse(<|MMSBibfile|>, <||>, <||>, <|\bibliographystyle{MMSBibstyle}
\bibliography{MMSBibfile}
|>)
\end{document}|>)
m4_divert(0)
HTML(<|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html> <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>MMSTitle</title>
<!-- LaTeX math -->
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']],
processEscapes: true}});
</script>
m4_ifelse(<|MMSHTMLHead|>, <||>, <||>, <|m4_include(MMSHTMLHead)|>)
</head><body>
<h1>MMSTitle</h1>
<P>|>)
TeX(<|
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{epsfig,amsfonts,natbib,url,xspace,listings, graphicx}
%code listing:
\lstset{columns=fullflexible, basicstyle=\small,
emph={size\_t,apop\_data,apop\_model,gsl\_vector,gsl\_matrix,gsl\_rng,FILE},emphstyle=\bfseries}
\def\setlistdefaults{\lstset{ showstringspaces=false,%
basicstyle=\small, language=C, breaklines=true,caption=,label=%
,xleftmargin=.34cm,%
,frameshape=
,frameshape={nnnynnnnn}{nyn}{nnn}{nnnynnnnn}
}
\lstset{columns=fullflexible, basicstyle=\small, emph={size_t,apop_data,apop_model,gsl_vector,gsl_matrix,gsl_rng,FILE,math_fn},emphstyle=\bfseries}
}
\setlistdefaults
\renewcommand{\sfdefault}{phv}
\usepackage{times, epsfig, latexsym, setspace, verbatim}
\def\link#1#2{#1\footnote{\url{#2}}}
%I think the Computer Modern teletype is too wide.
\usepackage[T1]{fontenc}
\renewcommand\ttdefault{cmtt}
\def\Re{{\mathbb R}}
m4_ifelse(<|MMSPreamble|>, <||>, <||>, <|m4_include(MMSPreamble)|>)
\begin{document}
\title{MMSTitle}
\author{MMSAuthor}
\maketitle
|>)