Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

longtable bug cause overflow #5557

Closed
annProg opened this issue Jun 6, 2019 · 7 comments
Closed

longtable bug cause overflow #5557

annProg opened this issue Jun 6, 2019 · 7 comments

Comments

@annProg
Copy link

annProg commented Jun 6, 2019

longtable bug description

there are some bugfix:

So, can pandoc not use longtable by default? May be able to add a property, manually specify longtable:

left  right
---  -----
a     b

: Title {.long}

when use {.long}, generate longtable. otherwise use booktabs

MWE

\documentclass{article}
\usepackage{longtable}

% helper pkg
\usepackage[pass, showframe]{geometry}
\usepackage{lipsum}
\usepackage{listings}

\begin{document}
\begin{lstlisting}[float=htbp]
hello
\end{lstlisting}

\begin{figure}[t]
  a\\b\\c\\d
\end{figure}
\begin{lstlisting}[float=htbp]
hello2
\end{lstlisting}

\lipsum[1] % optional
\begin{lstlisting}[float=htbp]
hello3
\end{lstlisting}

\begin{longtable}{l}
  cell
\end{longtable}
\begin{lstlisting}[float=htbp]
hello4
\end{lstlisting}

\lipsum
\end{document}
@jgm
Copy link
Owner

jgm commented Jun 6, 2019

Pandoc does use longtable by default. I have occasionally seen awkward layout relating to this bug. My own solution was just to patch longtable.sty as indicated, and I haven't seen the issue since then.

There's already an issue for adding configurable support for other table formats, #1023.
So I think this issue should be closed in favor of that one. (You may want to add this information to that issue.)

See also #4392

@cykerway
Copy link

cykerway commented Jun 6, 2020

This issue is pretty old but I think the longtable environment hasn't yet been completely fixed, despite the patch given by: https://www.latex-project.org/cgi-bin/ltxbugs2html?pr=tools/3512

For those who don't need longtable but a quick fix to make markdown tables usable with floats, I suggest a patch on the pandoc latex writer itself (in src/Text/Pandoc/Writers/LaTeX.hs):

781c781
<                         return ("\\toprule" $$ contents $$ "\\midrule")
---
>                         return ("\\hline" $$ contents $$ "\\hline")
788c788
<               then return "\\toprule"
---
>               then return "\\hline"
800,804c800,802
<   return $ "\\begin{longtable}[]" <>
<               braces ("@{}" <> colDescriptors <> "@{}")
<               -- the @{} removes extra space at beginning and end
<          $$ capt
<          $$ firsthead
---
>   return $ "\\begin{table}[]"
>          $$ "\\centering"
>          $$ "\\begin{tabular}" <> braces (colDescriptors)
806d803
<          $$ "\\endhead"
808,809c805,808
<          $$ "\\bottomrule"
<          $$ "\\end{longtable}"
---
>          $$ "\\hline"
>          $$ "\\end{tabular}"
>          $$ capt
>          $$ "\\end{table}"

It works with pandoc-2.5 and switches the default table environment to table and tabular. I think it is sane providing a simple table environment as default and more advanced ones in command line options. But the discussion better be done in #1023.

@annProg
Copy link
Author

annProg commented Jun 6, 2020

@cykerway My solution is to use lua filter, use tabu replace longtable. Ref: https://github.com/annProg/PanBook/blob/master/extensions/tabu/tabu.lua

@JCGoran
Copy link

JCGoran commented Jul 8, 2021

Any progress on this? I tried using the patch from here, but to no avail, the figures I insert after the table go completely off-page, so for now I'm forced to manually change all instances of longtable to a tabular inside of a table (tedious), or making the whole document half-empty by spamming \pagebreak after each \end{longtable} to ensure figures aren't mangled.
I assume that #4392 could fix the problem, but it doesn't seem to have had much activity for quite some time now...

@jgm
Copy link
Owner

jgm commented Jul 8, 2021

I haven't seen the issue since patching longtable.sty locally.
Maybe you could post an example that we could try to reproduce.

@jolars
Copy link

jolars commented Oct 14, 2021

This seems to have been finally solved (latex3/latex2e#137)! So I guess we just have to wait for texlive 2022.

@ibutra
Copy link

ibutra commented Jan 6, 2022

@jgm I tried every patch I found and every version of longtable.sty I found online but the problem persists for me. As we still need to wait for the updated texlive until planned April. Can you tell me which patch you applied or attach your longtable.sty here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants