3

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, 2017 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, 2017 at 10:15
  • @Fran Any workaround?
    – Francesco
    Jul 24, 2017 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, 2017 at 8:26
  • @Fran Yes, this seems a good solution (answer) to me
    – Francesco
    Jul 25, 2017 at 8:28

1 Answer 1

4

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .