Options for docx (Word) files
Table of Contents
asdocx uses asdocx_defaults.ado file to set options permanently. For more details on this, please visit this section. In this section, we are going to understand how to change various formatting options for the current session. Once set, these options are sticky and will be used by asdocx until Stata is restarted or the option is set to a different value.
1. save(file_name)
The default file file name is MyFile.docx
. However, this can be changed using the save(file_name.ext)
option. So, let say we wish to save the file as Panel Data Regression
, where y x1 x2 x3 are variables in our dataset, our regression code will be:
asdocx reg y x1 x2 x3, save(Panel Data Regression) replace
Since .docx
is the default, we can skip it from the file name to save some typing. However, the following code also works. Please note the .docx
addition to the file name. If we were to send the results to MS Excel, then typing .xlsx
is must.
asdocx reg y x1 x2 x3, save(Panel Data Regression.docx) replace
2. append / replace
The default behavior of asdocx is to append tables and contents to the existing file, therefore, option append is option. Option replace is used to replace any existing file.
3. 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 sum, replace fs(14)
4. Font family
The default font family is Garamond. Fonts for the entire document can be set using option dfont(fontname
). Fonts for individual items such as table or text can be set using the font(fontname)
option. fontname
may be any valid font installed on the user’s computer. Let say we wish to change the document font to Calibri
and the current table font to Arial
, the code would be:
asdocx sum, replace font(Arial) dfont(Calibri)
5. Decimal points
The default is to report three decimal points. This can be changed using the dec(#)
option. The following code reports 4 decimal points:
asdocx sum, replace dec(4)
6. Document orientation
The default layout is portrait
. To change document orientation to landscape
:
* Use landscape orientation
asdocx sum, replace landscape
* Change back to Portrait asdocx sum, replace portrait
7. Paper size
The possible values for paper are letter, legal, A3, A4, and B4JIS. The default paper size is A4
, to change it to legal, use option paper(legal)
:
asdocx sum, paper(Legal)
8. Table layout
The table layout can be fixed
, autofit
or auto
. The default is fixed
. The fixed
layout sets the same width for all columns in the table. It is similar to the Fixed-Column Width in MS Word. When auto
is specified, the column width automatically resizes to fit the window. It is similar to ‘AutoFit-Window‘ in MS Word. When autofit
is specified, the table width is determined by the overall table layout algorithm, which automatically resizes the column width to fit the contents. In MS Word parlance, it is similar to ‘AutoFit-Contents‘. For tables with many columns, it is recommended to use the autofit
or auto
option. One example could be to report the detailed summary statistics using autofit
option. To set the table layout to autofit
:
asdocx sum, detail table_layout(autofit)
9.1 Table Title
Table title is set using the title(title text)
option. Therefore, if the desired table title is Table 5: Descriptive Statistics
, the code would be:
asdocx sum, detail title(Table 5: Descriptive Statistics)
9.2 Table Title : Font Size
To set the table title font size, use option fs_title(#).
asdocx sum, title(Summary) fs_title(18) replace
9.3 Table Title : Bold
The table title is bold by default. To use normal font face, use option title_bold(0) or title_bold(1) to use bold face again.
asdocx sum, title(Summary) title_bold(1) replace
9.4 Table Title : Italic
To make the table title italic, use option title_italic(1)
asdocx sum, title(Summary) title_italic(1) replace
10. Table alignment
To set the table alignment, use option table_align()
. The possible values for this option are left, right, and center. Note that setting the table alignment has no visible effect if the table has the default width.
* Set the table align to left
asdocx sum, detail table_align
(left)
11. 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.