Skip to content
This repository was archived by the owner on Feb 14, 2020. It is now read-only.
This repository was archived by the owner on Feb 14, 2020. It is now read-only.

Stop figure number from showing if in pdf #32

Description

@Ipsta

When I use knitr::spin and chunk for figure and use captionioner to lable the figure, in the appropriate chunk, I get an MD file which I then use Rmarkdown to generate into pdf, html and word files.

For PDF I get double numbering and for word, I get the right figure numbering. How should I resolve this?

Activity

  1. tomvanengeland commented on Aug 22, 2018

    @tomvanengeland

    Hi,
    I think it could be fairly straightforward to add the extraction of the caption to the captioner function. The folowing addition in bold in the code chunk from the captioner function should take care of this.
    ...
    if (display == FALSE) {
    return(invisible())
    }
    else if (display == "full" || display == "f") {
    return(paste0(prefix, obj_num, ": ", caption))
    }
    else if (display == "caption") {
    return(caption)
    }

    else if (display == "cite" || display == "c") {
    return(paste0(prefix, obj_num))
    }
    else if (display == "num" || display == "n") {
    return(obj_num)
    }
    else {
    warning("Invalid display mode used. Caption was still saved.")
    return(invisible())
    }
    ...

    This will work for latex once you define a fig_num function similar to the one below but with the parameter "display" set to "caption". Then you use the fig_num function to define the fig.cap option in the header line of the R code chunk. To get it working for both html and pdf (latex) in the same Rmd file you can follow the attached working exmple.

    fig_num <- captioner(prefix="Fig.", display="caption")
    f.ref <- function(x) {
    fig_num(x,display="num")
    }

    working example.Rmd.zip

  2. tomvanengeland commented on Aug 22, 2018

    @tomvanengeland

    Note that I have not tested it for word output.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions