Autofilling Values - princecon/ra-manual GitHub Wiki
Hard-coded 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.
In-text values
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.
LyX
- Go to
Document,Settings, and thenLaTeX Preamble. Paste in the following. Here,scalarsrefers to ascalars.texfile located in the same directory as the LyX document. You may renamescalarsaccording to your preferences. For example,\input{../more_scalars}would refer to amore_scalars.texfile located in the parent directory of the LyX document.
\input{scalars}
- Using a program of your choice (e.g., Stata), generate file
scalars.texwith the following. Here,valuerefers to the value you wish to include in the document. You may renamescalarmathandscalartextaccording to your preferences. Note that LaTeX places restrictions on how new commands may be named.
\newcommand{\scalarmath}{value}
\newcommand{\scalartext}{\textnormal{value}}
- Use the macro
\scalarmathto display the value in math mode. Use the macro\scalartextto display the value in text mode.
LaTeX
- In the document preamble, paste in the following. Here,
scalarsrefers to ascalars.texfile located in the same directory as the LyX document. You may renamescalarsaccording to your preferences. For example,\input{../more_scalars}would refer to amore_scalars.texfile located in the parent directory of the LyX document.
\input{scalars}
- Using a program of your choice (e.g., Stata), generate file
scalars.texwith the following. Here,valuerefers to the value you wish to include in the document. You may renamescalarmathandscalartextaccording to your preferences. Note that LaTeX places restrictions on how new commands may be named.
\newcommand{\scalarmath}{value}
\newcommand{\scalartext}{\textnormal{value}}
- Use the macro
\scalarmathto display the value in math mode. Use the macro\scalartextto display the value in text mode.
Comments
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.