I am making a CV in R Markdown, and I have the following code that uses Latex to render multiple bibliography sections based on the keywords={} argument in the bibtex reference:
---
header-includes: \usepackage{tikz,xcolor,listings,CormorantGaramond,fontawesome,academicons,mfirstuc,fancyhdr,multicol}
output:
bookdown::pdf_document2:
citation_package: biblatex
toc: no
latex_engine: lualatex
biblio-style: apa
bibliography: MyPubs.bib
---
\underline{\textbf{Publications}}
\begin{refsection}
\setlength\bibitemsep{\baselineskip}
\nocite{*}
\noindent\printbibliography[heading=none, keyword = mypapers]
\end{refsection}
\underline{\textbf{Presentations}}
\begin{refsection}
\setlength\bibitemsep{\baselineskip}
\nocite{*}
\printbibliography[heading=none, keyword = mypresentations]
\end{refsection}
The resulting behavior is as follows: R Markdown renders a PDF with two separate bibliographies: a Publication section that pulls references from my .bib file that have the mypublications keywords, and a separate section for Presentations (from refs with mypresentations keywords).
The output is PDF, but how do you duplicate this behavior in HTML?
I'm having a hard time finding info on this; is it possible? Thank you in advance for any guidance you can provide.
Related
Referring to the description:
Wikipedia:Contents categorises types of articles in Wikipedia.
https://en.wikipedia.org/wiki/Wikipedia:Contents
I want to extract all of the articles referring to types of contents, like Outlines, Lists. These articles are in the same namespace as normal articles, so filtering pages by namespace did not work.
I looked at info at:
https://meta.wikimedia.org/wiki/Data_dumps/What%27s_available_for_download
and at content and content models tables in :
https://www.mediawiki.org/wiki/Manual:Database_layout
https://www.mediawiki.org/wiki/Manual:Content_models_table
but I could not find a way to solve the problem.
How could I extract the pageids, or titles, of the pages that belongs to types of content as Outline and List, mentioned in https://en.wikipedia.org/wiki/Wikipedia:Contents ?
Which Dumps contains such info ?
I've used this query at Quarry which I think does what you're asking:
SELECT page_title,page_id from page
Where (page_title LIKE 'List_%'
OR page_title LIKE 'Outline_%')
and page_is_redirect = 0
and page_namespace = 0
You can see the results here: https://quarry.wmcloud.org/query/71439
I would like to use a single footnote multiple times in HTML Quarto. The problem is that once I create a footnote and use it twice, it will be shown as two footnotes. Here is a reproducible example:
---
title: "Footnote multiple times"
editor: visual
format: html
---
Some example text for a footnote[^1].
Some example text for same footnote[^1].
[^1]: Example footnote.
Output:
As you can see, the footnote is shown as two separate footnotes (duplicated) while I created one footnote. So I was wondering if anyone knows how to create one footnote and use it multiple times in HTML Quarto?
We can sort of mimic how quarto would have generated the html code creating for footnotes to get similar appearances (that's why I have used r function so that I don't have to write the same thing multiple times).
---
title: "Footnote multiple times"
format: html
---
```{r}
#| echo: false
gen_fn <- function(n, id) {
# n is number of footnote
# id is a unique id for that footnote
paste0('<sup>', n, '</sup>')
}
```
Some example text for a footnote`r gen_fn(1, "fn1")`
Some example text for same footnote`r gen_fn(1, "fn1")`
Another text containing different footnotes`r gen_fn(2, "fn2")`
```{=html}
<footer>
<h2>Footnotes</h2>
<ol style="padding-left: 1rem;">
<li id="fn1"><p>Example footnote.</p></li>
<li id="fn2"><p>More footnote.</p></li>
</ol>
</footer>
```
R Markdown with knitr can add a prefix (usually a letter) to figure and table numbers when knitting/compling to PDF. When knitting to PDF, the following code will do the job:
```{=tex}
\renewcommand{\thetable}{S\arabic{table}}
\renewcommand{\thefigure}{S\arabic{figure}}
```
The result will be
Figure S1.1.
rather than
Figure 1.1
Is there a way to achieve the same when knitting to HTML?
I am writing an R/Shiny code that generates HTML reports for my users' data using an R markup template. I want to give the user the option to omit certain sections from the report. Which is easy to do for the sections themselves, but not obvious for the sections' headlines and their ToC entries. Any advice would be greatly appreciated!
My code passes the list of sections to include in the report via the params variable of the rmarkdown::render function. And the omitted sections of the R markup file are indeed not evaluated. However, the ToC entries and headlines for those (empty) sections still end up in the resulting HTML file. I browsed the manual but could not find any way to use the markup code parameters to exclude desired sections of the markup file.
---
output:
html_document:
theme: yeti
df_print: kable
toc: true
toc_float:
collapsed: true
smooth_scroll: false
params:
ExpData: data.frame()
set_title: "My Data Report"
Sections_to_include: list()
title: "`r params$set_title`"
---
.....................................
.....................................
.....................................
# ANOVA
```{r , eval = ( "ANOVA" %in% params$Sections_to_include)}
# Here be the code that generates my ANOVA table
# lme_model is calculated from params$ExpData in the preceding
# code chunks
kable(ANOVA(lme_model))
```
If the params$Sections_to_include list does not include the element "ANOVA" then the code chunk above will not be evaluated and the ANOVA table won't be printed. However, the section headline ANOVA will still be included in the HTML document preceding an empty section, and the ToC will contain a link to that headline. Which is of course what the
# ANOVA
line instructs R markup to do. I wonder if there is any parameter that would allow me to instruct the R markup renderer to ignore that line.
One solution I can see is to change the workflow to (i) generate a customized R markup document from the basic template according to the options desired (e.g., using UNIX command line tools), and (ii) then render the customized markup file into an HTML doc. But I wonder if R markup / knitr provide a simpler built-in solution?
Thank you all!
You can do it using the "asis" engine. It's likely helpful to write a little function to decide on whether something should be included. Here's your example modified to leave out "ANOVA", but include two other sections.
---
output:
html_document:
theme: yeti
df_print: kable
toc: true
toc_float:
collapsed: true
smooth_scroll: false
params:
ExpData: data.frame()
set_title: "My Data Report"
Sections_to_include: ["Other", "More"]
title: "`r params$set_title`"
---
.....................................
.....................................
.....................................
```{r include=FALSE}
library(knitr)
include <- function(section) {
section %in% params$Sections_to_include
}
```
```{asis , echo=include("Other")}
# Other section
This is a section that I do want to include, this time.
```
```{asis echo=include("ANOVA")}
# ANOVA
```
```{r , echo = include("ANOVA"), eval = include("ANOVA")}
# Here be the code that generates my ANOVA table
# lme_model is calculated from params$ExpData in the preceding
# code chunks
kable(ANOVA(lme_model))
```
```{asis , echo=include("More")}
# More
So is this one.
```
I'm not sure how to programmatically generate that vector of section names in Sections_to_include from within YAML, but you can always pass parameter values in your call to rmarkdown::render.
I am using R's XML package to extract all possible data over a wide variety of html and xml files. These files are basically documentation or build properties or readme file.
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE chapter PUBLIC '-//OASIS//DTD DocBook XML V4.1.2//EN'
'http://www.oasis-open.org/docbook/xml/4.0 docbookx.dtd'>
<chapter lang="en">
<chapterinfo>
<author>
<firstname>Jirka</firstname>
<surname>Kosek</surname>
</author>
<copyright>
<year>2001</year>
<holder>Jiří Kosek</holder>
</copyright>
<releaseinfo>$Id: htmlhelp.xml,v 1.1 2002/05/15 17:22:31 isberg Exp $</releaseinfo>
</chapterinfo>
<title>Using XSL stylesheets to generate HTML Help</title>
<?dbhtml filename="htmlhelp.html"?>
<para>HTML Help (HH) is help-format used in newer versions of MS
Windows and applications written for this platform. This format allows
to pack several HTML files together with images, table of contents and
index into single file. Windows contains browser for this file-format
and full-text search is also supported on HH files. If you want know
more about HH and its capabilities look at <ulink
url="http://msdn.microsoft.com/library/tools/htmlhelp/chm/HH1Start.htm">HTML
Help pages</ulink>.</para>
<section>
<title>How to generate first HTML Help file from DocBook sources</title>
<para>Working with HH stylesheets is same as with other XSL DocBook
stylesheets. Simply run your favorite XSLT processor on your document
with stylesheet suited for HH:</para>
</section>
</chapter>
My goal is to just use xmlValue after parsing the tree using htmlTreeParse or xmlTreeParse using something like this (for xml files ..)
Text = xmlValue(xmlRoot(xmlTreeParse(XMLFileName)))
However, there is one error when I do this for both xml and html files. If there are child nodes at level 2 or more, the text fields get pasted without any space in between them.
For example, in the above example
xmlValue(chapterInfo) is
JirkaKosek2001JiKosek$Id: htmlhelp.xml,v 1.1 2002/05/15 17:22:31 isberg Exp
The xmlValues of each child node (recursive) is pasted together without adding space between them. How can I get xmlValue to add a whitespace while extracting this data
Thanks a lot for your help in advance,
Shivani
According to the documentation, xmlValue only works
on single text nodes, or on "XML nodes that contain a single text node".
Spaces in non-text nodes are apparently not kept.
However, even in the case of a single text node,
your code would strip the white spaces.
library(XML)
doc <- xmlTreeParse("<a> </a>")
xmlValue(xmlRoot(doc))
# [1] ""
You can add the ignoreBlanks=FALSE and useInternalNodes=TRUE
arguments to xmlTreeParse, to keep all the whitespace.
doc <- xmlTreeParse(
"<a> </a>",
ignoreBlanks = FALSE,
useInternalNodes = TRUE
)
xmlValue(xmlRoot(doc))
# [1] " "
# Spaces inside text nodes are preserved
doc <- xmlTreeParse(
"<a>foo <b>bar</b></a>",
ignoreBlanks = FALSE,
useInternalNodes = TRUE
)
xmlValue(xmlRoot(doc))
# [1] "foo bar"
# Spaces between text nodes (inside non-text nodes) are not preserved
doc <- xmlTreeParse(
"<a><b>foo</b> <b>bar</b></a>",
ignoreBlanks = FALSE,
useInternalNodes = TRUE
)
xmlValue(xmlRoot(doc))
# [1] "foobar"