LyXHeader and caption importing longtable-file in LyX

Information and discussion about LyX, a WYSIWYM editor, available for Linux, Windows and Mac OS X systems.
Post Reply
gnarlyx
Posts: 4
Joined: Wed Nov 27, 2013 7:40 pm

Header and caption importing longtable-file in LyX

Post by gnarlyx »

I am trying to import a longtable formatted .tex-file into LyX. The file works fine with TeXStudio, but after import into LyX the caption is repeated and the footer disappears.

Here is some example code:

Code: Select all

\documentclass{article}
\usepackage{longtable}
\providecommand{\tabularnewline}{\\}

\begin{document}
\begin{longtable}{l*{4}{c}} \caption{Regression table\label{tab1}}\\ \hline\hline\endfirsthead\hline\endhead\hline\endfoot\endlastfoot
                    &\multicolumn{1}{c}{(1)}&\multicolumn{1}{c}{(2)}&\multicolumn{1}{c}{(3)}&\multicolumn{1}{c}{(4)}\\
                    &\multicolumn{1}{c}{Price}&\multicolumn{1}{c}{Price}&\multicolumn{1}{c}{Price}&\multicolumn{1}{c}{Price}\\
\hline
Weight (lbs.)       &       1.747&       3.465&       3.413&       3.163\\
                    &      (2.72)&      (5.49)&      (2.97)&      (2.89)\\
[1em]
Mileage (mpg)       &      -49.51&       21.85&       9.289&      -75.61\\
                    &     (-0.57)&      (0.29)&      (0.11)&     (-0.92)\\
[1em]
Car type            &            &      3673.1&            &            \\
                    &            &      (5.37)&            &            \\
[1em]
Turn Circle (ft.)   &            &            &      -195.6&      -398.1\\
                    &            &            &     (-1.56)&     (-3.22)\\
[1em]
Displacement (cu. in.)&            &            &       8.204&       3.390\\
                    &            &            &      (0.93)&      (0.50)\\
[1em]
Gear Ratio          &            &            &     -1349.5&            \\
                    &            &            &     (-1.05)&            \\
[1em]
0b.foreign\#1b.rep78 &            &            &           0&            \\
                    &            &            &         (.)&            \\
[1em]
0b.foreign\#2.rep78  &            &            &       303.4&            \\
                    &            &            &      (0.19)&            \\
[1em]
0b.foreign\#3.rep78  &            &            &       431.6&            \\
                    &            &            &      (0.29)&            \\
[1em]
0b.foreign\#4.rep78  &            &            &      -715.1&            \\
                    &            &            &     (-0.45)&            \\
[1em]
0b.foreign\#5.rep78  &            &            &      3735.1&            \\
                    &            &            &      (1.76)&            \\
[1em]
1o.foreign\#1b.rep78 &            &            &           0&            \\
                    &            &            &         (.)&            \\
[1em]
1o.foreign\#2o.rep78 &            &            &           0&            \\
                    &            &            &         (.)&            \\
[1em]
1.foreign\#3.rep78   &            &            &      4586.2&            \\
                    &            &            &      (2.20)&            \\
[1em]
1.foreign\#4.rep78   &            &            &      5240.1&            \\
                    &            &            &      (2.84)&            \\
[1em]
1.foreign\#5.rep78   &            &            &      4166.3&            \\
                    &            &            &      (2.50)&            \\
[1em]
Constant            &      1946.1&     -5853.7&      4161.5&     13338.6\\
                    &      (0.54)&     (-1.73)&      (0.68)&      (2.70)\\
\hline
Observations        &          74&          74&          69&          74\\
\hline\hline
\multicolumn{5}{l}{\footnotesize \textit{t} statistics in parentheses}\\
\end{longtable}

\end{document}

It seems that LyX does import the tags \endfirsthead, \endhead, \endfoot and \endlastfoot at the right place. Do you have any idea, how I could fix this after importing the table?

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

scottkosty
Site Moderator
Posts: 542
Joined: Sat Sep 01, 2012 6:38 am

Header and caption importing longtable-file in LyX

Post by scottkosty »

Which version of LyX are you using and which OS?

This seems to import fine for me with LyX 2.1 Beta 2 on Ubuntu. Can you check the attachment to make sure that the output is indeed correct (I might have misunderstood you). You can download 2.1 Beta 2 here: ftp://ftp.lyx.org/pub/lyx/devel/lyx-2.1/lyx-2.1.0beta2

Note that it might have been fixed in a 2.0.x version also so if you don't want to try beta2 (although it seems very stable to me), you could try a later version.
Attachments
mwe.pdf
(34.87 KiB) Downloaded 260 times
gnarlyx
Posts: 4
Joined: Wed Nov 27, 2013 7:40 pm

Re: Header and caption importing longtable-file in LyX

Post by gnarlyx »

I am using LyX Version 2.0.6 on Win 7, also I have recently done a MikeTeX update.
Attachments
example.pdf
Note the repeated caption
(38.92 KiB) Downloaded 334 times
scottkosty
Site Moderator
Posts: 542
Joined: Sat Sep 01, 2012 6:38 am

Re: Header and caption importing longtable-file in LyX

Post by scottkosty »

Was the pdf that I posted correct?
gnarlyx
Posts: 4
Joined: Wed Nov 27, 2013 7:40 pm

Re: Header and caption importing longtable-file in LyX

Post by gnarlyx »

Yes, your PDF was correct, there is no repetition of the caption.
Last edited by gnarlyx on Wed Nov 27, 2013 10:35 pm, edited 1 time in total.
scottkosty
Site Moderator
Posts: 542
Joined: Sat Sep 01, 2012 6:38 am

Re: Header and caption importing longtable-file in LyX

Post by scottkosty »

OK, then I'm guessing it was a bug that was recently fixed in LyX. If you do end up trying a newer LyX version and you see the same behavior, please post a bug report: http://www.lyx.org/trac

In the meantime I can post the .lyx file to generate that pdf. It should work for you (assuming the bug is in tex2lyx). Would that be useful or do you need to import many other tables?
gnarlyx
Posts: 4
Joined: Wed Nov 27, 2013 7:40 pm

Re: Header and caption importing longtable-file in LyX

Post by gnarlyx »

I need to import more tables, so I will try the new version. Thank you!
scottkosty
Site Moderator
Posts: 542
Joined: Sat Sep 01, 2012 6:38 am

Re: Header and caption importing longtable-file in LyX

Post by scottkosty »

Sounds good. Let us know how it goes.
Post Reply