-
Notifications
You must be signed in to change notification settings - Fork 2
/
txt.sthlp
161 lines (117 loc) · 5.94 KB
/
txt.sthlp
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
{smcl}
{smcl}
{marker title}{...}
{title:Title}
{phang}
{cmdab:txt} {hline 2} Prints string and values of scalar expressions or macros
in dynamic document. By default, the command writes a
text paragraph. The primary purpose of the command is writing dynamic text to
interpret analysis results in the dynamic document. This command belongs
to {help Weaver} package, but it also supports the
{help MarkDoc} package. The syntax for both packages is similar, but
the {cmdab:txt} command behaves differently based on which package is in use.
If Weaver log is on, {cmd:txt} functions for Weaver package only.
This document only describes the {bf:txt} command in Weaver package. For using the
command in {help MarkDoc} package
{browse "https://github.com/haghish/MarkDoc/wiki/txt":see the MarkDoc documentation on GitHub wiki}
{marker syntax}{...}
{title:Syntax}
{p 4 4 2}
Prints dynamic text on the Weaver log or smcl log. The {opt c:ode} subcommand
prints the output "as is" in the dynamic document.
{cmdab:txt} [{opt c:ode}] [{it:display_directive} [{it:display_directive} [{it:...}]]]
{pstd}where the {it:display_directive} is
{help weaver_markup:Weaver Markup}
{cmd:"}{it:double-quoted string}{cmd:"}
{p 8 16 2}{cmd:{c 96}"}{it:compound double-quoted string}{cmd:"{c 39}}{p_end}
[{help format:{bf:%}{it:fmt}}] [{cmd:=}]{it:{help exp}}
{cmd:_skip(#)}
{cmdab:_col:umn:(}{it:#}{cmd:)}
{cmdab:_n:ewline}[{cmd:(}{it:#}{cmd:)}]
{cmdab:_d:up:(}{it:#}{cmd:)}
{cmd:,}
{cmd:,,}
{marker description}{...}
{title:Description}
{p 4 4 2}
{bf:txt} prints dynamic text i.e. strings and values of scalar expressions or macros in the Weaver or the
smcl log-file. {cmd:txt} also prints output from the user-written Stata programs. Any of the
supported markup languages can be used to alter the string and scalar expressions. This command
is to some extent similar to {cmd:display} command in Stata. For example,
it can be used to carry out a mathematical calculation by typing {cmd:txt 1+1}. It also
supports many of the display directives as well.
{p 4 4 2}
Note that in contrast to the {help display} command that prints the
{help scalar} unformatted, the {cmd:txt} command uses the default
{bf:%10.2f} format for displaying the scalar. This feature helps the users avoid
specifying the format for every scalar, due to popularity of this
format. However, specifying the format expression can overrule the default format.
For example:
{cmd:. scalar num = 10.123}
{cmd:. txt "The value of the scalar is " %5.1f num}
{pstd}
The example above will print the scalar with only 1 decimal number.
This feature only supports scalar interpretation and does not affect
the {help macro} contents. {break}
{title:Display directives}
{pstd}
The supported {it:display_directive}s are used in do-files and programs
to produce formatted output. The directives are
{synoptset 32}
{synopt:{bf:{help weaver_markup:Weaver Markup}}}A simplified markup language for
annotating the content of the HTML log{p_end}
{synopt:{cmd:"}{it:double-quoted string}{cmd:"}}displays the string without
the quotes{p_end}
{synopt:{cmd:{c 96}"}{it:compound double-quoted string}{cmd:"{c 39}}}display the string
without the outer quotes; allows embedded quotes{p_end}
{synopt:[{cmd:%}{it:fmt}] [{cmd:=}] {cmd:exp}}allows results to be formatted;
see {bf:{mansection U 12.5FormatsControllinghowdataaredisplayed:[U] 12.5 Formats: Controlling how data are displayed}}.{p_end}
{synopt:{cmd:_skip(}{it:#}{cmd:)}}skips {it:#} columns{p_end}
{synopt:{cmd:_column(}{it:#}{cmd:)}}skips to the {it:#}th column{p_end}
{synopt:{cmd:_newline}}goes to a new line{p_end}
{synopt:{cmd:_newline(}{it:#}{cmd:)}}skips {it:#} lines{p_end}
{synopt:{cmd:_dup(}{it:#}{cmd:)}}repeats the next directive {it:#} times{p_end}
{synopt:{cmd:,}}displays one blank between two directives{p_end}
{synopt:{cmd:,,}}places no blanks between two directives{p_end}
{p2colreset}{...}
{title:Mathematical notations}
{p 4 4 2}
The {bf:txt} command can be used for writing mathematical notations in Weaver
package, both in HTML and LaTeX log files. Writing mathematical notations in the
HTML log is made possible by including {bf:MathJax} engine, a JavaScript-based
engine for rendering LaTeX notations in HTML format.
To do so, notations should begin with "{bf:\(}" and end with "{bf:\)}" for
rendering notations within the text and double dollar sign "{bf:$$}" or alternatively,
the "{bf:\[}" and "{bf:\]}" for rendering
notations in a separate line. For more information in this
regard, see {help Weaver_mathematical_notation:mathematical notations} documentation.
{p 4 4 2}
When Weaver package is running, the {opt c:ode} subcommand appends the dynamic text to the
{marker examples}{...}
{title:Examples}
{pstd}As a hand calculator:
{phang2}{cmd:. txt 2 * 2}
{pstd}As might be used in do-files and programs:
{phang2}{cmd:. sysuse auto}{p_end}
{phang2}{cmd:. summarize price}{p_end}
{phang2}{cmd:. txt "mean of Price variable is " r(mean) " and SD is " %9.3f r(sd)}{p_end}
{pstd}If the text only includes string and macro, the double quotations can be ignored.
The {cmd:txt} command will interpret all of the {it:display_directives} and
scalars as string (so it{c 39}s not recommended):
{phang2}{cmd:. local n 9.9}{p_end}
{phang2}{cmd:. txt Not recommended, but you may also print the value of {c 96}n{c 39} without double quote}{p_end}
{title:Author}
{p 4 4 2}
{bf:E. F. Haghish} {break}
Center for Medical Biometry and Medical Informatics {break}
University of Freiburg, Germany {break}
{it:and} {break}
Department of Mathematics and Computer Science {break}
University of Southern Denmark {break}
[email protected] {break}
{p 4 4 2}
{browse "www.haghish.com/weaver":Weaver Homepage} {break}
Package Updates on {browse "https://www.twitter.com/Haghish":Twitter}
{hline}
{p 4 4 2}
This help file was dynamically produced by {help markdoc:MarkDoc Literate Programming package}