What is the best way to add HTML tables to a Quarto Document #6602
Replies: 6 comments 14 replies
-
Dear @friosavila, you can not have a nicely HTML formated table included in a generated HTML and PDF. You will have better results reading the table into R or Python and let them generate the HTML and LaTeX (for PDF). Whithout access to your
Quarto/Pandoc does not know how to translate iframes to LaTeX (for PDF output) and skip the iframe. |
Beta Was this translation helpful? Give feedback.
-
One thing to be aware here is that table inclusion needs to happen inside a pandoc RawBlock. So your Markdown needs to look like this:
It cannot look like this:
The
This is because include shortcodes are only processed at the top level of the QMD file, and not inside code blocks. I would recommend pre-processing the .htm file in a pre-render script. |
Beta Was this translation helpful? Give feedback.
-
A related question. |
Beta Was this translation helpful? Give feedback.
-
Perhaps im getting confused here
For example, say I get the following:
```{=html}
<table> <caption><span data-qmd="As described in @Lovelace1864, computers are great."></span></caption>
<thead> <tr> <th><span data-qmd="_Header1_"></span></th>
<th><span data-qmd="_Header 2_"></span></th> </tr>
</thead> <tbody> <tr> <td><span data-qmd=""></span></td>
<td>Regular output</td> </tr> </tbody> </table>
```
Now, How do I refer to this table in text?
something like @tbl-html1 is an html table that i can refer to in text.
I imagine that something like {#tbl-html1} would have to be added somewhere
in the HTML table-code right?
perhaps something like this:
```{=html}
<table>
<caption> Example Table <span data-qmd="{#tbl-tb1}"></span></caption>
<thead> <tr> <th><span data-qmd="_Header1_"></span></th>
<th><span data-qmd="_Header 2_"></span></th> </tr>
</thead> <tbody> <tr> <td><span data-qmd=""></span></td>
<td>Regular output</td> </tr> </tbody> </table>
```
Thank you
…On Wed, Aug 23, 2023 at 10:30 PM Carlos Scheidegger < ***@***.***> wrote:
Use <span data-qmd="your markdown goes here"></span>:
https://quarto.org/docs/prerelease/1.3/tables.html
—
Reply to this email directly, view it on GitHub
<#6602 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ASZKKFWW4ZOGJOVHRF2GAGDXW24DTANCNFSM6AAAAAA33U3UMI>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
For future people, see #11067 for a good workflow. In short, this now works:
|
Beta Was this translation helpful? Give feedback.
-
Description
Say that I have a nicely formated table in -regress.htm-.
What would be the best way to include this table in a document, so it can be rendered in multiple formats.
So far, I'm aware of 2
1: {{< include regress.htm >}}
2: <iframe src="regress.htm" width="100%" height="500px" align="centered" ></iframe>
When rendering in HTML, The first option has some problems rendering the table correctly, as it creates something like:
in the first cell.
the second option displays correctly, but the height is not adjusted automatically. (Needs to be adjusted manually)
In PDF. 1) creates a very badly rendered output,
and 2) doesn't even render the table.
Thank you
F
Beta Was this translation helpful? Give feedback.
All reactions