Adding text

We can write text to our output file with option text(text lines). This is useful when we want to add details or comments with the Stata output. In fact, this option makes asdocx really flexible in terms of adding tables and paragraph at the same time. We never have to leave the Stata interface to add comments or interpretation with the results.

Control Words

The following control words are used to set text formatting properties.
1. \b : If a sentence contains \b, it will be shown in bold. However, this option is not sticky. So, new lines will be shown in regular font face.

2. fs(#) : Option fs() is used to set font size. The default is 12pt. This option is sticky. Unless changed, the font size will be inherited from previous execution of the code.

3. \i : To show text in italic. This option is not sticky. So, new lines will be shown in regular font face.

4. \par : To start a new paragraph

5. \super : Show text in super-script, e.g

asdocx, text(The R\super2 is 0.25)

will be shown as The R2 is 0.25

6. \sub : Show text in sub-script, e.g

asdocx, text(The B\sub1 is 0.98)

will be shown as The B1 is 0.98


Options are written outside the brackets of the text(). The following options can be used to format the given text.

1. h1 or heading1: Either h1 or heading1 is used to make the current line as heading 1. Similarly, h2 or heading1 , h3 or heading3h9 or heading9 can be used.

2. title : option title is used to make the current line as document title.

3. fs() to set font size : The default font size is 12 points. This can be changed to any desired value using the fs(#) option. Therefore, to set the font size as 14 pt, the code would be

asdocx, text(This is my new text line) fs(14)

4. Font family : The default font family is Garamond. This can be changed using the font(fontname) option. fontname may be any valid font installed on the user’s computer. Let say we wish to change the font family to Arial, the code would be:

asdocx, text(Yet another line) font(Arial)

5. Page breaks
Page breaks can be added with the option  pagebreak(before) or pagebreak(after)pagebreak(before) inserts a page break before a given table. pagebreak(after) inserts a page break after the table.


Consider the following examples:

* Start a new document and write title
asdocx, text("Panel Data Analysis") title replace

* Write some text with font size of 18pt
asdocx, text("Results and Summary Statistics.") fs(18)

* Add bold text and keep font size at 12pt
asdocx, text("\b I a am bold item. ") fs(12)

* Change font size to 14pt
asdocx, text("This section of the report will present the results and analysis.")  fs(14)

* Add italic text
asdocx, text(\i Notes to the tables are reported in table notes.)

* Revert back to normal text
asdocx, text(" Significance level is `reported with *, **, ***. ")

* Add super-script
asdocx, text("The R\super2 of the model is 0.0764.")

* Add subscript
asdocx, text("The coefficient B\sub1 indicates a positive ...")

The output from the above codes is given below.
asdocx text stata