Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Figure and table referencing #258

Closed
ssinari opened this issue Apr 13, 2016 · 16 comments
Closed

Figure and table referencing #258

ssinari opened this issue Apr 13, 2016 · 16 comments

Comments

@ssinari
Copy link

ssinari commented Apr 13, 2016

Is it possible to do LaTeX style figure and table referencing using pander?

@daroczig
Copy link
Member

pander has no direct helper functions for this, as fig/table references are not part of pandoc's markdown. Although you can use any LaTeX commands in a markdown document if your output format is PDF, but honestly -- I'd rather go with eg xtable for more features if you are tied to PDF. Unfortunately, this feature is not supported in other document format as far as I know -- so closing this ticket, but please feel free to reopen/create a new one if I misunderstood the question.

@ssinari
Copy link
Author

ssinari commented Apr 14, 2016

Hello Gergely,
Thanks for the quick response. Internal links in HTML are not that foreign.
Here is how it is done: example: Visit the
Useful Tips Section
. What needs to be done is the indexing part for the
fig/tables. I understand this may not be part of the formal markdown spec.
Here is some discussion on this issue and seems to have been incorporated
in pandoc markdown:
jgm/pandoc#261 (comment) and more
about scholarly markdown:
http://scholarlymarkdown.com/Scholarly-Markdown-Guide.html#differences-from-pandoc-1.
I think it might be beneficial to have the scholarly markdown syntax
supported. just my two cents.
Regards,

Shripad Sinari
University of Arizona
Statistician - BIO5 Institute
1657 E. Helen St / Keating Bldg, Cube 0200D7
Ph: (520) 626-2325
Email: shripad@email.arizona.edu

On Wed, Apr 13, 2016 at 9:29 PM, Gergely Daróczi notifications@github.com
wrote:

pander has no direct helper functions for this, as fig/table references
are not part of pandoc's markdown http://pandoc.org/README.html.
Although you can use any LaTeX commands in a markdown document if your
output format is PDF, but honestly -- I'd rather go with eg xtable for
more features if you are tied to PDF. Unfortunately, this feature is not
supported in other document format as far as I know -- so closing this
ticket, but please feel free to reopen/create a new one if I misunderstood
the question.


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
#258 (comment)

@daroczig daroczig reopened this Apr 15, 2016
@daroczig
Copy link
Member

Hi Shripad,

this is a great idea! I was not aware that with the most recent versions of pandoc it's that easy to add HTML attributes to images. Based on this, I will add an optional argument to pandoc.image to support this feature -- although this will be a HTML-only thing it seems.

About the indexing part: I think that should be done rather in JS as part of the HTML template used in pandoc. We do something similar in the package-bundled JS file to build a table of content from the h1, h2 etc tags at https://github.com/Rapporter/pander/blob/master/inst/includes/javascripts/custom.js#L48

Unfortunately, the next few weeks are very busy, so please do not expect a related commit in the near future, but I will get back to this thread in early May.

Best,
Gergely

@ssinari
Copy link
Author

ssinari commented Apr 15, 2016

Thanks Gergely,
Looking forward to it when you are done.
Regards,

Shripad Sinari
University of Arizona
Statistician - BIO5 Institute
1657 E. Helen St / Keating Bldg, Cube 0200D7
Ph: (520) 626-2325
Email: shripad@email.arizona.edu

On Thu, Apr 14, 2016 at 9:28 PM, Gergely Daróczi notifications@github.com
wrote:

Hi Shripad,

this is a great idea! I was not aware that with the most recent versions
of pandoc it's that easy to add HTML attributes to images. Based on this,
I will add an optional argument to pandoc.image to support this feature
-- although this will be a HTML-only thing it seems.

About the indexing part: I think that should be done rather in JS as part
of the HTML template used in pandoc. We do something similar in the
package-bundled JS file to build a table of content from the h1, h2 etc
tags at
https://github.com/Rapporter/pander/blob/master/inst/includes/javascripts/custom.js#L48

Unfortunately, the next few weeks are very busy, so please do not expect a
related commit in the near future, but I will get back to this thread in
early May.

Best,
Gergely


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
#258 (comment)

@yasirs
Copy link
Contributor

yasirs commented May 2, 2016

Stupid question: Why can't reference links be used for cross-referencing tables and figures?

@daroczig
Copy link
Member

daroczig commented May 3, 2016

@yasirs I think the problematic point here is not how to reference stuff, but how to refer to tables and figures. Or I miss something. Can you please provide a simple example?

@yasirs
Copy link
Contributor

yasirs commented May 3, 2016

@daroczig You are right. They're too different things.

According to jgm/pandoc#813 (comment) there are pandoc-extensions for

Pander could support these in the meantime.

@daroczig
Copy link
Member

daroczig commented May 5, 2016

Good resources, thank you, @yasirs!

@daroczig
Copy link
Member

daroczig commented May 14, 2016

A quick question before I push some updates regarding this:

What do you think?

@ssinari
Copy link
Author

ssinari commented May 15, 2016

Hello Gergely,
I would prefer a new argument that takes the identifier as a string just to
keep them separate.
Regards,
Shripad.

On Saturday, May 14, 2016, Gergely Daróczi notifications@github.com wrote:

A quick question before I push some updates regarding this:

  • referencing tables via pandoc-tablenos is already pretty easy, as
    you can include the label in the caption as per
    https://github.com/tomduck/pandoc-tablenos#basic-syntax -- do you
    think it's OK or should we add a new argument to pandoc.table?
  • referencing images is a bit trickier with pandoc-fignos as the label
    should be appended right after the image path, so this needs a new argument
    in pandoc.image. Is it something you would use?

What do you think?


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
#258 (comment)

Shripad
Tucson, Az.
Sent from my iPad. Please excuse typos.

@yasirs
Copy link
Contributor

yasirs commented May 18, 2016

I think the label should be an optional argument to table with the default being the chunk name, to be compatible with bookdown and it's behavior with knitr::kable. Also, the tables produced as part of pandoc.htest.

@guillaumechaumet
Copy link

Hi guys. Did this new feature is available?

@krlmlr
Copy link
Contributor

krlmlr commented Dec 4, 2016

I use the following in conjunction with bookdown:

pander(..., caption = "(\\#tab:table-label) Table caption")

In the text, I then refer to the table via \@ref(tab:table-label) .

@guillaumechaumet
Copy link

guillaumechaumet commented Dec 5, 2016

I use this solution
pander(...,caption="\\label{tabs:NSV} My caption")

and then \ref{tabs:NSV} in the text part.

Thanks

@ssinari
Copy link
Author

ssinari commented Dec 5, 2016 via email

@daroczig
Copy link
Member

Thanks all for your very helpful feedback! I'm closing this in favor of the above-referenced ticket and hope to get this done there soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants