-
Notifications
You must be signed in to change notification settings - Fork 2
Autofilling Values
To facilitate reproducibility, figures and tables should always be generated programmatically and never include hard-coded values. The tablefill
package of gslab_make
is a useful tool to help create complex tables.
Frequently, it is necessary to include values derived from calculations in the text of a document. For example, we may wish to reference a coefficient from a regression specification. To facilitate reproducibility and avoid text from becoming outdated, it is recommended to include values programatically. Below, we detail methods for doing so.
Using a program of your choice (e.g., R), generate the file scalars.tex
containing the scalars formatted as new TeX command, as illustrated below. The new command should be named after the scalar (e.g. scalarnamemath
and scalarnametext
). The command should output the scalar value. Note that LaTeX places restrictions on how new commands may be named.
\newcommand{scalarnamemath}{value} % this command displays your scalar value in math mode
\newcommand{scalarnametext}{\textnormal{value}} % this command displays your scalar value as normal text
If you are using R, you can use the AutoFill
function from gslab_r
to export scalars. For sample code on how to pre-format scalars and use the AutoFill
function, access here.
- Go to
Document
,Settings
, and thenLaTeX Preamble
. Paste in the following. Here,scalars
refers to ascalars.tex
file located in the same directory as the LyX document. You may renamescalars
according to your preferences. For example,\input{../more_scalars}
would refer to amore_scalars.tex
file located in the parent directory of the LyX document. To create ascalars.tex
file, see Creating scalars.
\input{scalars}
- Use the command
\scalarnamemath
to display the value in math mode. Use the command\scalarnametext
to display the value in text mode.
- In the document preamble, paste in the following. Here,
scalars
refers to ascalars.tex
file located in the same directory as the LaTeX document. You may renamescalars
according to your preferences. For example,\input{../more_scalars}
would refer to amore_scalars.tex
file located in the parent directory of the LaTeX document. To create ascalars.tex
file, see Creating scalars.
\input{scalars}
- Use the command
\scalarnamemath
to display the value in math mode. Use the command\scalarnametext
to display the value in text mode.
In cases where including a hard-coded value in-text is unavoidable, include a red LaTeX comment for fact-checking. Yellow LyX comments should be used for comments between coauthors to be resolved and deleted.
- Practice Task
- Autofilling Values
- Overleaf Workflow
- IT Support
- Research Clusters
- Legacy Tools
- Style Guides
- Mothballing Projects
- Recruiting on Social Media
- PhD Applications
- Gentzkow-Shapiro Lab Notes
- Allcott-Gentzkow Lab Notes