I am still learning tex. The following example allows me to check if a variable exists, and if it does then prints some text in the PDF. This works great. However, when I add in a href, this appears whether the variable exists or not. Driving me nuts as I cant find anything online even close to what im trying to do. Is it even possible?
\ifdefempty{\na}{}{\Sexpr{cve_descr_na}}\ is displaying a variable I have in R. This works well. However, \ifdefempty{\ds}{}{\Sexpr{cve_descr_ds}{\href{\Sexpr{url_ds_1}}{here }}}\ displays "here" even if ds is null.
\documentclass[11pt,a4paper, titlepage]{article}
\usepackage[margin=0.5in]{geometry}
\usepackage{tikz,fancyvrb}
\usepackage{helvet}%font
\usepackage{color}
\usepackage[hidelinks]{hyperref}
\usepackage{etoolbox}
\def\ds{cve_descr_ds}
\def\ui{cve_descr_ui}
\renewcommand{\familydefault}{\sfdefault}%sets fonts across document
\title{}
\date{}
\begin{document}
\fcolorbox{white}{green!65}{%
\parbox{17cm}{
\textbf{Your Cyber Vunerabilities}\\
\small
\ifdefempty{\na}{}{\Sexpr{cve_descr_na}}\\
\ifdefempty{\spf}{}{\Sexpr{cve_descr_spf}}\\
\ifdefempty{\ds}{}{\Sexpr{cve_descr_ds}{\href{\Sexpr{url_ds_1}}{here }}}\\
\ifdefempty{\ui}{}{\Sexpr{cve_descr_ui}{\href{\Sexpr{url_ui_1}}{here,}}}\\
}
}
\end{document}
Here is the resultant sweave; \documentclass[11pt,a4paper, titlepage]{article} \usepackage[margin=0.5in]{geometry} \usepackage{tikz,Sweave,fancyvrb} \usepackage{helvet}%font \usepackage{color} \usepackage[hidelinks]{hyperref} \usepackage{etoolbox} \def\ds{cve_descr_ds} \def\ui{cve_descr_ui}
\renewcommand{\familydefault}{\sfdefault}%sets fonts across document
\title{}
\date{}
\begin{document}
\input{HC-concordance}
\fcolorbox{white}{blue!65}{%
\parbox{5cm}{
\begin{center}
\textbf{About You}\\
\small
The Lakes
\\
Your business ranks in the highest 25 percent
\end{center}
}
}
\fcolorbox{white}{green!65}{%
\parbox{13cm}{
\textbf{Your Cyber Vunerabilities}\\
\small
\ifdefempty{\ds}{}{they can find more details{\href{}{here, }}}\\
\ifdefempty{\ui}{}{they can find more details {\href{https://nvd.nist.gov/vuln/detail/CVE-2016-6329}{here, }}}
}
\end{document}
}for\fcolorbox. We need to know what\Sexpris doing, and it might not be compatible with hyperref expansion. – daleif Dec 08 '17 at 14:53\dsisn't empty in your document! – Harald Hanche-Olsen Dec 08 '17 at 15:10cve_descr_dsas the expansion of\ds. If you want the contents of a variable from R in there, more magic is needed. I can't tell you what magic, though, since I am unfamiliar with R. – Harald Hanche-Olsen Dec 08 '17 at 15:18\edef\ui{\Sexpr{cve_descr_ui}}will put the value in\ui. If not, and this is more likely, the resulting contents of\uiwill be some bunch of cryptic TeX commands to get at the value. And that is not good enough for what you want to do. – Harald Hanche-Olsen Dec 08 '17 at 15:31