quarto-journals / elsevier

Quarto template for Elsevier Journals
https://quarto-journals.github.io/elsevier/
MIT License
54 stars 20 forks source link

5p layout not correctly rendered when table is added #24

Open SHolm3s opened 7 months ago

SHolm3s commented 7 months ago

Hi, I am using the elsevier quarto extension for a paper I am writing. When I add a markdown table, the 5p format is not rendering correctly. It is fine without the table, but with the table, some of the text in the beginning is cut off.

This is the render from the template file : image

Now when I just replace the content under the heading "Tables coming from R" with my own markdown table, I get this render: image

Everything above "Using CSL" is cut off! Could you help see why this is happening?

dragonstyle commented 7 months ago

This format should be trying to do the right thing with long tables in 2-column layouts, but I've seen when that code isn't working properly (e.g. before I added it).

I think a place to start is to add keep-tex: true to your document front matter, then inspect the latex that is produced to see whether we're correctly injecting the table handling.

We're basically hoping that this:

\usepackage{float}
\makeatletter
\let\oldlt\longtable
\let\endoldlt\endlongtable
\def\longtable{\@ifnextchar[\longtable@i \longtable@ii}
\def\longtable@i[#1]{\begin{figure}[H]
\onecolumn
\begin{minipage}{0.5\textwidth}
\oldlt[#1]
}
\def\longtable@ii{\begin{figure}[H]
\onecolumn
\begin{minipage}{0.5\textwidth}
\oldlt
}
\def\endlongtable{\endoldlt
\end{minipage}
\twocolumn
\end{figure}}
\makeatother

makes it into the latex.

One other thought- it's possible that since this is redefining longtable, if R/Quarto isn't producing longtables this may no longer be working. I know that we did a lot of work in this area for 1.4 (to make tables in LaTeX far more stable and reliable), so this is a real possibility. CC'ing @cscheid just in case he knows this off the top of his head.

SHolm3s commented 7 months ago

Thanks for the suggestion! I will see if I see it in the latex file and report back

SHolm3s commented 7 months ago

Hi, I checked the latex file, and the code that you mentioned is present in the generated latex. The top part is still cut off though

dragonstyle commented 7 months ago

Can you share the latex (or see whether the table in the document is a ‘longtable’)?

SHolm3s commented 7 months ago

I am attaching the latex file. I think I saw "longtable" at the end, longtable_cuts_off_text.txt

Thanks a lot for taking the time to help!

dragonstyle commented 7 months ago

Yeah it definitely seems like everything should be working, but it sure looks like the table is evading our special handling. I'll need to try to drill into the LaTeX more carefully to diagnose what is happening...

cscheid commented 7 months ago

Can you provide a .qmd file that causes this as well as the latex file?

SHolm3s commented 7 months ago

I actually am using quarto from jupyterlab and rendering the .ipynb file. But I made a qmd file too just now. The problem persists. I am attaching the qmd code in txt file elsevier5p_tablecutoff_qmd.txt

SHolm3s commented 7 months ago

Hi, Any luck with the debugging process ? Also I wanted to ask an unrelated question. Is there any way to span a figure across the 2 columns in 5p or 3p ?

MitchellAcoustics commented 4 days ago

Hi, Any luck with the debugging process ? Also I wanted to ask an unrelated question. Is there any way to span a figure across the 2 columns in 5p or 3p ?

Quarto provides the way to do this with figures with fig-env="figure*" https://quarto.org/docs/authoring/figures.html#environments

Some examples from a document I'm working on:

![Steps for calculating the SPI.](figures/SPI-framework.drawio.png){#fig-bespoke-spi width="100%" fig-env="figure*"}

It's not documented, but I got it to work with embedded figures by wrapping it in the fenced div.

::: {#fig-targets fig-env="figure*"}
{{< embed notebooks/SingleIndex-Code.ipynb#fig-targets >}}
:::

I haven't figured out how to get a table to span both columns though - that's what brought me to this issue! @dragonstyle is this possible with longtable?

I believe it can be done be done with table* in latex just like the figure environment, but quarto hasn't incorporated a table environment option yet.