1

I would like to pass a string from R script in order to run href in my rnw file. In the R script I have to include double \\ for the href otherwise I get error.

ifelse(is.na(url_ui_1)|is.null(url_ui_1)|url_ui_1=="",
       ui_string<-"",
       ui_string<-paste0("\\\\href{",url_ui_1,"}{ here}")
)

In the nrw file I pick up ui_string1 but as the string has \ it errors on me. Is there anyway to pass single \ so that the href code works?

\documentclass[11pt,a4paper, titlepage]{article}
\usepackage[margin=0.5in]{geometry}
\usepackage{tikz,Sweave,fancyvrb}
\usepackage{helvet}%font
\usepackage{color}
\usepackage[hidelinks]{hyperref}
\def\uistring{ui_string}
\renewcommand{\familydefault}{\sfdefault}%sets fonts across document
\title{}
\date{}
\begin{document}
\SweaveOpts{concordance=TRUE}
 \fcolorbox{white}{green!65}{%
 \parbox{13cm}{
 \textbf{Your Vunerabilities}\\
 \small
 \ifdefemtpy{\uistring}{}{ui_string}
}
}
\\
\\
\end{document}
  • Can you add as well your R code that seems to produce an error for you? (The actual rnw file) – Alex Recuenco Dec 11 '17 at 11:49
  • 1
    In any case, first you need to remove the double `\` that you have at the end of your latex file. That part will certainly produce an error. Since you are finishing a paragraph when there is no line to end. – Alex Recuenco Dec 11 '17 at 11:54
  • Ive managed to solve this! I simply had to add in four \ in my R code rather than one \. Now it all works nicely! – Siobhan Dec 11 '17 at 12:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.