2

I have a table with a column containing markdown formatted links. When pander decides how wide to make the columns, it (understandably) takes the width of the URL into account. Is there a way to over-ride this behaviour so I can make this column small; the linked text is very narrow.

Here is an example in markdown with the compiled result. I would like to make the second column take 10% of the width, as specified with the split.cells argument.

---
title: ''
output: pdf_document
---

```{r}
library('pander')
testDF <- data.frame(Description='some rather long description that I would like to take up the majority of the column width',
                     link='[Y](http://www.thelongesturlintheworld-no-I-mean-really-really-long-leik-so-looooooooooooooooooooooooooooooooooooooooooong.cooooooooooooooom)')
pander::pander(testDF,
               split.cells = c('90%','10%'), 
               split.table = 500,
               justify = 'left')
```

Image of compiled PDF

I'm aware that I could dig into the produced .tex file and change the widths with a find an replace - I was wondering if I could do this in a more reproducible manner.

James Owers
  • 7,948
  • 10
  • 55
  • 71
  • 1
    This is due to the long URL in your second column, which cannot be seen in the PDF output, but it's there in the markdown table. A possible solution would be to use [reference links](http://pandoc.org/README.html#reference-links) instead of the inline URLs. – daroczig Jun 01 '16 at 19:12
  • 1
    Reference links are certainly a good solution for static links. They can be a bit cumbersome if the links are generated from the data but certainly possible. In some situations, a pandoc filter can provide a cleaner solution. [Here](https://github.com/jknightlab/heatshock/blob/master/include/go-link.py) is an example of that approach, turning table entries of the form `GO:NNNNNNN` into links to the corresponding page at http://amigo.geneontology.org. – Peter Humburg Jan 31 '17 at 04:55

0 Answers0