wjschne / apaquarto

A quarto extension for creating APA7 documents in .docx, .html, and .pdf formats
https://wjschne.github.io/apaquarto/
Creative Commons Zero v1.0 Universal
170 stars 15 forks source link

Captions in Markdown tables #9

Closed drfurtado closed 1 year ago

drfurtado commented 1 year ago

Is there a way to use the prefix apatb- when inserting a markdown table (not in a r chunk)? I want to take advantage of the apa format for markdown tables.

Thank you.

wjschne commented 1 year ago

I hadn't thought to do this until you asked, so thank you. Setting up the tables manually with custom divs is possible, but it would be tedious. A more straightforward solution is to use the asis engine that outputs text as it is but also will take care of chunk options like the caption and the note below the table. There is now an example of how to do this in the updated template, but here is what it would look like:

In {apatb-mymarkdowntable}, there are some numbers.

```{asis}
#| label: apatb-mymarkdowntable
#| apa-cap: Figure caption of a markdown table
#| apa-note: This is a note below the markdown table.
#| echo: true

| Default | Left | Right | Center |
|---------|:-----|------:|:------:|
| 12      | 12   |    12 |   12   |
| 123     | 123  |   123 |  123   |
| 1       | 1    |     1 |   1    |
drfurtado commented 1 year ago

It works as expected! Thanks for this very helpful repo.

drfurtado commented 1 year ago

On a related note, is there a function to set the width of the tables to 100%?

wjschne commented 1 year ago

You can add more hyphens to make the table wider. For example:

```{asis}
#| label: apatb-mymarkdowntable
#| apa-cap: Figure caption of a markdown table
#| apa-note: This is a note below the markdown table.
#| echo: true

| Default | Left | Right | Center |
|:-------------------------------:|:-------------------------------:|:-------------------------------:|:-------------------------------:|
| 12      | 12   |    12 |   12   |
| 123     | 123  |   123 |  123   |
| 1       | 1    |     1 |   1    |
NeubertJonas commented 1 year ago

Rendering as PDF with the new markdown table results in an error and aborted export. (HTML and docx are fine).

compilation failed- error
File ended while scanning use of \efloat@xfloat.
<inserted text> 
                \par 
<*> template.tex

I'm using the latest version of tinytex (v2023.07.08). Error appears both on Quarto v1.3.353 and v.1.4.193.

Not sure if it is related, but I found an (older) StackExchange thread discussing this error here.

NeubertJonas commented 1 year ago

A missing empty line before the closing backticks was causing the error. Created a pull request to fix it.

wjschne commented 1 year ago

You can. It will work with .docx and .html, but not .pdf because my .pdf solution processes plots differently.


#| label: apafg-mymarkdownfigure

#| apa-cap: Figure caption 

#| apa-note: This is a note below figure.

#| echo: true

!()[myfigure.png]{width=6.5}

Can you let know why a markdown solution is needed instead of this:


#| label: apafg-importedgraphic

#| apa-cap: Figure caption 

#| apa-note: This is a note below figure.

knitr::include_graphics("myfigure.png ")

From: Furtado Jr., O. @.> Sent: Saturday, July 22, 2023 5:05 PM To: wjschne/apaquarto @.> Cc: W. Joel Schneider @.>; State change @.> Subject: Re: [wjschne/apaquarto] Captions in Markdown tables (Issue #9)

I hadn't thought to do this until you asked, so thank you. Setting up the tables manually with custom divs is possible, but it would be tedious. A more straightforward solution is to use the asis engine that outputs text as it is but also will take care of chunk options like the caption and the note below the table. There is now an example of how to do this in the updated template, but here is what it would look like:

In {apatb-mymarkdowntable}, there are some numbers.


#| label: apatb-mymarkdowntable
#| apa-cap: Figure caption of a markdown table
#| apa-note: This is a note below the markdown table.
#| echo: true

| Default | Left | Right | Center |
|---------|:-----|------:|:------:|
| 12      | 12   |    12 |   12   |
| 123     | 123  |   123 |  123   |
| 1       | 1    |     1 |   1    |

Can a similar solution be applied to figures?

—
Reply to this email directly, view it on GitHub <https://github.com/wjschne/apaquarto/issues/9#issuecomment-1646671723> , or unsubscribe <https://github.com/notifications/unsubscribe-auth/AB4J7WDTXVTX4VJPJZTT4P3XRQ577ANCNFSM6AAAAAAZYSZ6LM> .
You are receiving this because you modified the open/close state.  <https://github.com/notifications/beacon/AB4J7WHVSNGGQI6MFQC3NLTXRQ577A5CNFSM6AAAAAAZYSZ6LOWGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTTCEY3WW.gif> Message ID: ***@***.*** ***@***.***> >
drfurtado commented 1 year ago

You can. It will work with .docx and .html, but not .pdf because my .pdf solution processes plots differently. {asis} #| label: apafg-mymarkdownfigure #| apa-cap: Figure caption #| apa-note: This is a note below figure. #| echo: true !()[myfigure.png]{width=6.5} Can you let know why a markdown solution is needed instead of this: {r} #| label: apafg-importedgraphic #| apa-cap: Figure caption #| apa-note: This is a note below figure. knitr::include_graphics("myfigure.png ") From: Furtado Jr., O. @.> Sent: Saturday, July 22, 2023 5:05 PM To: wjschne/apaquarto @.> Cc: W. Joel Schneider @.>; State change @.> Subject: Re: [wjschne/apaquarto] Captions in Markdown tables (Issue #9) I hadn't thought to do this until you asked, so thank you. Setting up the tables manually with custom divs is possible, but it would be tedious. A more straightforward solution is to use the asis engine that outputs text as it is but also will take care of chunk options like the caption and the note below the table. There is now an example of how to do this in the updated template, but here is what it would look like: In {apatb-mymarkdowntable}, there are some numbers. ```{asis} #| label: apatb-mymarkdowntable #| apa-cap: Figure caption of a markdown table #| apa-note: This is a note below the markdown table. #| echo: true | Default | Left | Right | Center | |---------|:-----|------:|:------:| | 12 | 12 | 12 | 12 | | 123 | 123 | 123 | 123 | | 1 | 1 | 1 | 1 | Can a similar solution be applied to figures? — Reply to this email directly, view it on GitHub <#9 (comment)> , or unsubscribe https://github.com/notifications/unsubscribe-auth/AB4J7WDTXVTX4VJPJZTT4P3XRQ577ANCNFSM6AAAAAAZYSZ6LM . You are receiving this because you modified the open/close state. https://github.com/notifications/beacon/AB4J7WHVSNGGQI6MFQC3NLTXRQ577A5CNFSM6AAAAAAZYSZ6LOWGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTTCEY3WW.gif Message ID: @. @.> >

Thank you!!!

I have another related question. I am using crossref to mention the figures in text.

I noticed that if I use ({apafg-fig2}), it does not render. But I place a space after and before the brackets, it renders fine - ( {apafg-fig2} ). The problem is that there is an extra space in the rendered text: ( Figure 1 ). Would you happen to know an easy solution for this?

We created the rating scales for gallop ( {apafg-fig2} ) and vertical jump ( {apafg-fig3} ) following the procedures outlined in @furtado-gallagher-2012.

#| label: apafg-fig2
#| apa-cap: Rating scale for the skill of gallop.
knitr::include_graphics("images/dt-mermaid-loc-ga.png")
#| label: apafg-fig3
#| apa-cap: Rating scale for the skill of vertical jump.
knitr::include_graphics("images/dt-mermaid-loc-vj.png")
wjschne commented 1 year ago

The newest version now fixes this problem. You can now use ({apafg-fig2}) if you wish.

drfurtado commented 1 year ago

The newest version now fixes this problem. You can now use ({apafg-fig2}) if you wish.

Is there an update command, or do I need to reinstall the extension in Quarto?

wjschne commented 1 year ago

Yes, to update the extension, in the project's folder, execute this code in the terminal:

quarto update wjschne/apaquarto
drfurtado commented 1 year ago

Thanks for the prompt response and the awesome extension.

drfurtado commented 6 months ago

I hadn't thought to do this until you asked, so thank you. Setting up the tables manually with custom divs is possible, but it would be tedious. A more straightforward solution is to use the asis engine that outputs text as it is but also will take care of chunk options like the caption and the note below the table. There is now an example of how to do this in the updated template, but here is what it would look like:

In {apatb-mymarkdowntable}, there are some numbers.

```{asis}
#| label: apatb-mymarkdowntable
#| apa-cap: Figure caption of a markdown table
#| apa-note: This is a note below the markdown table.
#| echo: true

| Default | Left | Right | Center |
|---------|:-----|------:|:------:|
| 12      | 12   |    12 |   12   |
| 123     | 123  |   123 |  123   |
| 1       | 1    |     1 |   1    |

I get an error when I create a new document and try to add the table below. The error says, "Warning: don't know how to handle 'asis' engine output."

Rendering PDF
running xelatex - 1
  This is XeTeX, Version 3.141592653-2.6-0.999996 (TeX Live 2024) (preloaded format=xelatex)
   restricted \write18 enabled.
  entering extended mode

updating tlmgr

updating existing packages

compilation failed- error
Package longtable Error: longtable not in 1-column mode.

See the longtable package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.449 \begin{longtable}
                       []{@{}llrc@{}} 

see /Users/ovandef/Documents/GitHub/quarto_apa7_manuscript/testing-asis/example.log for more information.
#| label: tbl-table10
#| apa-cap: Figure caption of a markdown table
#| apa-note: This is a note below the markdown table.
#| echo: true

| Default | Left | Right | Center |
|---------|:-----|------:|:------:|
| 12      | 12   |    12 |   12   |
| 123     | 123  |   123 |  123   |
| 1       | 1    |     1 |   1    |