<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/create-a-glossary-in-r-markdown/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://liao961120.github.io/2018/10/24/glossary-maker.html"> Yongfu's Blog</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>I was thinking about creating a glossary in <a rel="nofollow" href="https://bookdown.org/yihui/bookdown/" target="_blank">bookdown</a> and found out that there was already an <a rel="nofollow" href="https://github.com/rstudio/bookdown/issues/199" target="_blank">issue</a> about it. I like Yihui’s <a rel="nofollow" href="https://github.com/rstudio/bookdown/issues/199#issuecomment-246888361" target="_blank">recommendation</a>: use Pandoc’s <a rel="nofollow" href="http://pandoc.org/MANUAL.html#definition-lists" target="_blank">definition lists</a>.<span></span> This was exactly what I had been doing, but I quickly found out that there was a major drawback – the definition lists <strong>won’t order alphabetically unless written in that way</strong>.</p>
<p>So I wrote an R function to reorder the definition lists written in R Markdown. Note that this functions <strong>only works for R Markdown files containing defintion lists exclusively</strong>. If the R Markdown files aren’t whole-definition-lists, the function will fail.</p>
<div>
<h2>Usage</h2>
<p>To order the definition lists alphabetically, simply put the Rmd file path in the function. To have a different output file, provide the output file path as the second argument.</p>
<pre><code>sort_def_list(&quot;glossary.Rmd&quot;)
# sort_def_list(&quot;glossary.Rmd&quot;, &quot;reordered.Rmd&quot;)</code></pre>
<p>The output in PDF looks like this (I used the <code>multicol</code> package)<a rel="nofollow" href="https://liao961120.github.io/2018/10/24/glossary-maker.html#fn1" target="_blank"><sup>1</sup></a>:</p>
<div>
<img src="https://i0.wp.com/raw.githubusercontent.com/liao961120/liao961120.github.io/master/post_source/glossary-maker/glossary.png?w=456&ssl=1" data-recalc-dims="1">
</div>
</div>
<div>
<h2>Source Code</h2>
<p>
</div>
<div>
<h2>Notes</h2>
<ol>
<li>
<p>To see the source R Markdown file, visit <a rel="nofollow" href="https://github.com/liao961120/liao961120.github.io/blob/master/post_source/glossary-maker/glossary.rmd" target="_blank"><code>glossary.rmd</code></a>. To see the output PDF, visit <a rel="nofollow" href="https://github.com/liao961120/liao961120.github.io/blob/master/post_source/glossary-maker/glossary.pdf" target="_blank"><code>glossary.pdf</code></a><a rel="nofollow" href="https://liao961120.github.io/2018/10/24/glossary-maker.html#fnref1" target="_blank"><img alt="↩" src="https://s.w.org/images/core/emoji/2.4/72x72/21a9.png" class="wp-smiley"></a></p>
</li>
</ol>
</div>
<p>
<a rel="nofollow" href="https://www.r-bloggers.com/" target="_blank">Visit R-bloggers</a><br>
Last updated: 2018-10-24</p>
	<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="https://liao961120.github.io/2018/10/24/glossary-maker.html"> Yongfu's Blog</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a rel="nofollow" href="https://www.r-project.org/" title="The R Project for Statistical Computing">R</a> news and <a rel="nofollow" href="https://www.r-bloggers.com/search/tutorial" title="R tutorials">tutorials</a> on topics such as: <a rel="nofollow" href="https://www.r-bloggers.com/search/data%20science" title="Data science">Data science</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data" title="Big Data">Big Data, <a rel="nofollow" href="https://www.r-users.com/" title="R jobs">R jobs</a>, visualization (<a rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2" title="ggplot and ggplot2 tutorials">ggplot2</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/boxplot" title="Boxplots using lattice and ggplot2 tutorials">Boxplots</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/map" title="Maps and gis">maps</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/animation" title="Animation in R">animation</a>), programming (<a rel="nofollow" href="https://www.r-bloggers.com/search/RStudio" title="RStudio IDE for R">RStudio</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/sweave" title="Sweave and literate programming">Sweave</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX" title="LaTeX in R">LaTeX</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/SQL" title="SQL and databases">SQL</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/eclipse" title="Eclipse IDE for R">Eclipse</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/git" title="git and github, Version Control System">git</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/hadoop" title="Large data in R using Hadoop">hadoop</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping" title="Web Scraping of google, facebook, yahoo, twitter and more using R">Web Scraping</a>) statistics (<a rel="nofollow" href="https://www.r-bloggers.com/search/regression" title="Regressions and ANOVA analysis tutorials">regression</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/PCA" title="principal component analysis tutorial">PCA</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/time+series" title="Time series">time series</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/trading" title="finance trading">trading</a>) and more...
<img width="1" alt="" src="http://feeds.feedburner.com/~r/RBloggers/~4/ZcC5p0aqvAY" height="1"></a></div>