ismayc / thesisdown

An updated R Markdown thesis template using the bookdown package

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Captions from \usepackage{subfig} does not align correctly

bttomio opened this issue · comments

I am trying to have captions for figures side by side using the package subfig.

It works very well in a normal RMarkdown file:

Screenshot from 2021-03-08 15-53-38

When using {thesisdown}, it somehow does not respect the fig.subcap argument. Here is the output:

Screenshot from 2021-03-08 15-54-20

Could you please take a look to see if it is possible to find a solution? Thanks in advance!


Here are the codes:

Normal .Rmd file

    ---
    title: "Untitled"
    date: "3/8/2021"
    output: pdf_document
    header-includes:
      - \usepackage{subfig}
    ---
    
    ```{r setup, include=FALSE}
    knitr::opts_chunk$set(echo = TRUE)
    ```
    
    ## Expected result

    ```{r Figures, echo=FALSE, out.width='30%', fig.cap = "Figures", fig.subcap = c("Figure 1", "Figure 2"), fig.align="center"}
    knitr::include_graphics(c("reed.jpg", "reed.jpg"), auto_pdf = T)
    ```

{ thesisdown}

Added to the YAML header:

    header-includes:
      - \usepackage{subfig}

Added to the introduction:

    **Subcaption does not align correctly**
    
    Is it possible to align it?

    ```{r Figures, echo=FALSE, out.width='30%', fig.cap = "Figures", fig.subcap = c("Figure 1", "Figure 2"), fig.align="center"}
    knitr::include_graphics(c("figure/reed.jpg", "figure/reed.jpg"))
    ```

It looks like there is something in either template.tex or reedthesis.cls that is causing this weird centering since bookdown::pdf_book renders fine after commenting out the \backmatter in the references Rmd. I'm digging in further to see what might be causing this.

If you comment out line 67 and 68 of template.tex, it looks like the captions are back to where you'd expect them. Not quite sure of the impact of this in other spots but let me know if that's what you are after.

That works perfectly! Thanks a lot, @ismayc. I should have searched for "caption" in the template.tex. I'll be more careful next time before opening an issue. Thanks once again!

No problem! It was good for me to do some digging 😀

This issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org whenever possible) and link to this issue. If a reprex is not applicable, recording a short Loom video showing what you are seeing can go a long way in helping to diagnose problems.