<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Publishing DTD v1.0 20120330//EN" "JATS-journalpublishing1.dtd">
<article xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink" article-type="research-article">
<front>
<journal-meta>
<journal-id journal-id-type="publisher-id">JDS</journal-id>
<journal-title-group><journal-title>Journal of Data Science</journal-title></journal-title-group>
<issn pub-type="epub">1683-8602</issn>
<issn pub-type="ppub">1680-743X</issn>
<issn-l>1680-743X</issn-l>
<publisher>
<publisher-name>School of Statistics, Renmin University of China</publisher-name>
</publisher>
</journal-meta>
<article-meta>
<article-id pub-id-type="publisher-id">JDS998</article-id>
<article-id pub-id-type="doi">10.6339/21-JDS998</article-id>
<article-categories><subj-group subj-group-type="heading">
<subject>Computing in Data Science</subject></subj-group></article-categories>
<title-group>
<article-title>Reproducible Science with LATEX</article-title>
</title-group>
<contrib-group>
<contrib contrib-type="author">
<name><surname>Bar</surname><given-names>Haim</given-names></name><email xlink:href="mailto:haim.bar@uconn.edu">haim.bar@uconn.edu</email><xref ref-type="aff" rid="j_jds998_aff_001">1</xref><xref ref-type="corresp" rid="cor1">∗</xref>
</contrib>
<contrib contrib-type="author">
<name><surname>Wang</surname><given-names>HaiYing</given-names></name><xref ref-type="aff" rid="j_jds998_aff_001">1</xref>
</contrib>
<aff id="j_jds998_aff_001"><label>1</label>Department of Statistics, <institution>University of Connecticut</institution>, Storrs, CT, <country>USA</country></aff>
</contrib-group>
<author-notes>
<corresp id="cor1"><label>∗</label>Corresponding author. Email: <ext-link ext-link-type="uri" xlink:href="mailto:haim.bar@uconn.edu">haim.bar@uconn.edu</ext-link>.</corresp>
</author-notes>
<pub-date pub-type="ppub"><year>2021</year></pub-date><pub-date pub-type="epub"><day>28</day><month>1</month><year>2021</year></pub-date>
<volume>19</volume><issue>1</issue><fpage>111</fpage><lpage>125</lpage>
<supplementary-material id="S1" content-type="archive" xlink:href="jds998_s001.zip" mimetype="application" mime-subtype="x-zip-compressed">
<caption>
<title>Supplementary Material</title>
<p>Detailed examples and documentation are available in a GitHub repository at <uri>https://github.com/Ossifragus/runcode</uri>. The <sans-serif>runcode</sans-serif> LATEX package is available via CTAN, and the <italic>talk2stat</italic> Python package for the server-mode is available at <uri>https://pypi.org/project/talk2stat/</uri>.</p>
</caption>
</supplementary-material>
<history>
<date date-type="received"><month>8</month><year>2020</year></date>
<date date-type="accepted"><month>11</month><year>2020</year></date>
</history>
<permissions><copyright-statement>2021 The Author(s). Published by the School of Statistics and the Center for Applied Statistics, Renmin University of China.</copyright-statement><copyright-year>2021</copyright-year>
<license license-type="open-access" xlink:href="https://creativecommons.org/licenses/by/4.0/">
<license-p>Open access article under the <ext-link ext-link-type="uri" xlink:href="https://creativecommons.org/licenses/by/4.0/">CC BY</ext-link> license.</license-p></license></permissions>
<abstract>
<p>This paper proposes a procedure to execute external source codes from a LATEX document and include the calculation outputs in the resulting Portable Document Format (pdf) file automatically. It integrates programming tools into the LATEX writing tool to facilitate the production of reproducible research. In our proposed approach to a LATEX-based scientific notebook the user can easily invoke any programming language or a command-line program when compiling the LATEX document, while using their favorite LATEX editor in the writing process. The required LATEX setup, a new <sans-serif>Python</sans-serif> package, and the defined preamble are discussed in detail, and working examples using <sans-serif>R</sans-serif>, <sans-serif>Julia</sans-serif>, and <sans-serif>MatLab</sans-serif> to reproduce existing research are provided to illustrate the proposed procedure. We also demonstrate how to include system setting information in a paper by invoking shell scripts when compiling the document.</p>
</abstract>
<kwd-group>
<label>Keywords</label>
<kwd>literate programming</kwd>
<kwd>reproducibility</kwd>
<kwd>scientific notebook</kwd>
<kwd><monospace>--shell-escape</monospace></kwd>
</kwd-group>
</article-meta>
</front>
<back>
<ref-list id="j_jds998_reflist_001">
<title>References</title>
<ref id="j_jds998_ref_001">
<mixed-citation publication-type="other"> <string-name><surname>Allaire</surname> <given-names>J</given-names></string-name>, <string-name><surname>Xie</surname> <given-names>Y</given-names></string-name>, <string-name><surname>McPherson</surname> <given-names>J</given-names></string-name>, <string-name><surname>Luraschi</surname> <given-names>J</given-names></string-name>, <string-name><surname>Ushey</surname> <given-names>K</given-names></string-name>, <string-name><surname>Atkins</surname> <given-names>A</given-names></string-name>, et al. (2020). <italic>rmarkdown: Dynamic Documents for R</italic>. package version 2.1.</mixed-citation>
</ref>
<ref id="j_jds998_ref_002">
<mixed-citation publication-type="book"> <string-name><surname>Bates</surname> <given-names>D</given-names></string-name>, <string-name><surname>Maechler</surname> <given-names>M</given-names></string-name> (<year>2019</year>). <source>Matrix: Sparse and Dense Matrix Classes and Methods</source>. <comment>R package version 1.2-16</comment>.</mixed-citation>
</ref>
<ref id="j_jds998_ref_003">
<mixed-citation publication-type="other"> <string-name><surname>Chang</surname> <given-names>W</given-names></string-name>, <string-name><surname>Cheng</surname> <given-names>J</given-names></string-name>, <string-name><surname>Allaire</surname> <given-names>J</given-names></string-name>, <string-name><surname>Xie</surname> <given-names>Y</given-names></string-name>, <string-name><surname>McPherson</surname> <given-names>J</given-names></string-name> (2020). <italic>shiny: Web Application Framework for R</italic>. R package version 1.5.0.</mixed-citation>
</ref>
<ref id="j_jds998_ref_004">
<mixed-citation publication-type="journal"> <string-name><surname>Csardi</surname> <given-names>G</given-names></string-name>, <string-name><surname>Nepusz</surname> <given-names>T</given-names></string-name>, <etal>et al.</etal> (<year>2006</year>). <article-title>The igraph software package for complex network research</article-title>. <source>InterJournal, complex systems</source>, <volume>1695</volume>(<issue>5</issue>): <fpage>1</fpage>–<lpage>9</lpage>.</mixed-citation>
</ref>
<ref id="j_jds998_ref_005">
<mixed-citation publication-type="journal"> <string-name><surname>Gentleman</surname> <given-names>R</given-names></string-name>, <string-name><surname>Temple Lang</surname> <given-names>D</given-names></string-name> (<year>2007</year>). <article-title>Statistical analyses and reproducible research</article-title>. <source>Journal of Computational and Graphical Statistics</source>, <volume>16</volume>(<issue>1</issue>): <fpage>1</fpage>–<lpage>23</lpage>.</mixed-citation>
</ref>
<ref id="j_jds998_ref_006">
<mixed-citation publication-type="other"> <string-name><surname>Ioannidis</surname> <given-names>JPA</given-names></string-name> (2005). Why most published research findings are false. <italic>PLOS Medicine</italic>, 2(8).</mixed-citation>
</ref>
<ref id="j_jds998_ref_007">
<mixed-citation publication-type="journal"> <string-name><surname>Ji</surname> <given-names>P</given-names></string-name>, <string-name><surname>Jin</surname> <given-names>J</given-names></string-name> (<year>2016</year>). <article-title>Coauthorship and citation networks for statisticians</article-title>. <source>Annals of Applied Statistics</source>, <volume>10</volume>(<issue>4</issue>): <fpage>1779</fpage>–<lpage>1812</lpage>.</mixed-citation>
</ref>
<ref id="j_jds998_ref_008">
<mixed-citation publication-type="journal"> <string-name><surname>Jin</surname> <given-names>J</given-names></string-name> (<year>2015</year>). <article-title>Fast community detection by SCORE</article-title>. <source>Annals of Statistics</source>, <volume>43</volume>(<issue>1</issue>): <fpage>57</fpage>–<lpage>89</lpage>.</mixed-citation>
</ref>
<ref id="j_jds998_ref_009">
<mixed-citation publication-type="journal"> <string-name><surname>Knuth</surname> <given-names>DE</given-names></string-name> (<year>1984</year>). <article-title>Literate programming</article-title>. <source>The Computer Journal</source>, <volume>27</volume>(<issue>2</issue>): <fpage>97</fpage>–<lpage>111</lpage>.</mixed-citation>
</ref>
<ref id="j_jds998_ref_010">
<mixed-citation publication-type="chapter"> <string-name><surname>Leisch</surname> <given-names>F</given-names></string-name> (<year>2002</year>). <chapter-title>Sweave: Dynamic generation of statistical reports using literate data analysis</chapter-title>. In: <source>Compstat</source>, <fpage>575</fpage>–<lpage>580</lpage>. <publisher-name>Springer</publisher-name>.</mixed-citation>
</ref>
<ref id="j_jds998_ref_011">
<mixed-citation publication-type="journal"> <string-name><surname>Schulte</surname> <given-names>E</given-names></string-name>, <string-name><surname>Davison</surname> <given-names>D</given-names></string-name>, <string-name><surname>Dye</surname> <given-names>T</given-names></string-name>, <string-name><surname>Dominik</surname> <given-names>C</given-names></string-name> (<year>2012</year>). <article-title>A multi-language computing environment for literate programming and reproducible research</article-title>. <source>Journal of Statistical Software</source>, <volume>46</volume>(<issue>3</issue>): <fpage>1</fpage>–<lpage>24</lpage>.</mixed-citation>
</ref>
<ref id="j_jds998_ref_012">
<mixed-citation publication-type="chapter"> <string-name><surname>Xie</surname> <given-names>Y</given-names></string-name> (<year>2014</year>). <chapter-title>knitr: A comprehensive tool for reproducible research in R</chapter-title>. In: <source>Implementing Reproducible Computational Research</source> (<string-name><given-names>V</given-names> <surname>Stodden</surname></string-name>, <string-name><given-names>F</given-names> <surname>Leisch</surname></string-name>, <string-name><given-names>RD</given-names> <surname>Peng</surname></string-name>, eds.). <publisher-name>Chapman and Hall/CRC</publisher-name>. ISBN <isbn>978-1466561595</isbn>.</mixed-citation>
</ref>
<ref id="j_jds998_ref_013">
<mixed-citation publication-type="book"> <string-name><surname>Xie</surname> <given-names>Y</given-names></string-name> (<year>2015</year>). <source>Dynamic Documents with R and knitr</source>. <publisher-name>Chapman and Hall/CRC</publisher-name>, <publisher-loc>Boca Raton, Florida</publisher-loc>, <edition>2nd edition</edition> edition. ISBN <isbn>978-1498716963</isbn>.</mixed-citation>
</ref>
<ref id="j_jds998_ref_014">
<mixed-citation publication-type="other"> <string-name><surname>Xie</surname> <given-names>Y</given-names></string-name> (2020). <italic>knitr: A General-Purpose Package for Dynamic Report Generation in R</italic>. R package version 1.28.</mixed-citation>
</ref>
<ref id="j_jds998_ref_015">
<mixed-citation publication-type="book"> <string-name><surname>Xie</surname> <given-names>Y</given-names></string-name>, <string-name><surname>Allaire</surname> <given-names>J</given-names></string-name>, <string-name><surname>Grolemund</surname> <given-names>G</given-names></string-name> (<year>2018</year>). <source>R Markdown: The Definitive Guide</source>. <publisher-name>Chapman and Hall/CRC</publisher-name>, <publisher-loc>Boca Raton, Florida</publisher-loc>. ISBN <isbn>9781138359338</isbn>.</mixed-citation>
</ref>
<ref id="j_jds998_ref_016">
<mixed-citation publication-type="other"> <string-name><surname>Zeileis</surname> <given-names>A</given-names></string-name> (2014). <italic>ineq: Measuring Inequality, Concentration, and Poverty</italic>. R package version 0.2-13.</mixed-citation>
</ref>
</ref-list>
</back>
</article>
