title: R Markdown html: main and axis labels of plots as text suitable for search-function
body: <p>I want to generate a R markdown <strong>html</strong> document with plots and it should be possible to jump to a certain plot by search-function (in my example there are 3 plots and I want to jump in the html-doc to the plot, where the main is &quot;rivers&quot;).
  I think, the problem is, that main and axis labels of a plot are grafical elements, like the plot itself, and not text. So the search-function doesn't work.</p>
  <p>Of course it would be possible to add manually text before each plot, but as all my plots are generated with a for-loop, I don_t know how to do it.</p>
  <p>is there a possibilty to include text-output in this kind of for-loop or are there other ideas, how the main or axis labels of a plot can be suitable for search-function?</p>
  <p>thanks in advance!</p>
  <pre><code>---
  title: &quot;search function test&quot;
  author: &quot;Michel Grün&quot;
  date: &quot;last edited `r format(Sys.Date(),'%d.%m.%Y')`&quot;
  output: 
    html_document:
      df_print: paged
  ---
  
  
  knitr::opts_chunk$set(echo = TRUE,warning = FALSE)
  
  
  
  
  df&lt;-data.frame(x=seq(1,20),
                 trees=rnorm(20,4,3),
                 mountains=rnorm(20,6,3),
                 rivers=rnorm(20,4,4))
  
  
  
  for(i in 2:length(colnames(df))){
    plot(df$x,df[,i],
         main=colnames(df)[i],
         xlab=colnames(df)[1],
         ylab=colnames(df)[i])
  }
  
  </code></pre>
  <p><strong>solved in another issue</strong>: <a href="https://stackoverflow.com/a/57034752/16578253">https://stackoverflow.com/a/57034752/16578253</a></p>
  <p>in this issue, the question is slightly different, but a solution shown there was also the solution for my problem. The idea is to create headings + outputs within a loop. As result, in the output dokument every header is followed by a plot and the header is of course suitable for search-function. It's important to use the argument results='asis' in the chunk konfiguration to allow that cat() is interpreted as Markdown syntax. Furthermore the
  cat()ing tshould be surrounded by some newlines to make sure it's interpreted properly.</p>