2

How to use the todo package in R Markdown-generated LaTeX documents?

To load packages, it is possible to add them to the document's header with header-includes:. This successfully works with \usepackage{hyperref} and its styling (\hypersetup{colorlinks=true}), but doesn't seem to allow to add inline todo{}s.

---
title: "Untitled"
author: "Test"
date: "7/24/2017"
output: pdf_document
header-includes:
   - \usepackage{todo}
   - \usepackage{hyperref}
   - \hypersetup{colorlinks=true}
---

[Link styling works](www.example.com) but \todo{todo does not}.

which generates

enter image description here

6
  • 1
    Maybe you want to use really the package todonotes? – Fran Jul 24 '17 at 10:01
  • 1
    Anyway the problem is not related in with Rmarkdow but with the todo package, that do not make the automatic internal \label{todolbl:1} . – Fran Jul 24 '17 at 10:15
  • @Fran Any workaround? – Francesco Jul 24 '17 at 13:24
  • Look like a bug of the package, but you can insert the \label{todolbl:1}, \label{todolbl:1}, etc. manually. But what I would do is just change "todo" by "todonotes" in the YAML header and add \listoftodos at the end of the .Rmd file. – Fran Jul 25 '17 at 8:26
  • @Fran Yes, this seems a good solution (answer) to me – Francesco Jul 25 '17 at 8:28
3

A good alternative is use the \todo command but from the todonotes package. Example:

mwe

---
title: "Untitled"
author: "Test"
date: "7/24/2017"
output: pdf_document
header-includes:
   - \usepackage[colorinlistoftodos]{todonotes}
   - \hypersetup{colorlinks=true,linkcolor=blue!30!black}
   - \geometry{rmargin=1.5in} 
---
[Link styling works](www.example.com)
\todo{Without load \texttt{hyperref} yourself!} 
as well as margin notes (but add some space to the right margin!)  
\todo[color=green!50,inline]{... or use  \texttt{todonotes} inline}.
\listoftodos

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.