-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Add option to specify table env. in LaTeX output #4392
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
base: main
Are you sure you want to change the base?
Conversation
Is there something blocking this PR? |
MANUAL.txt
Outdated
`--latex-table-environment=longtable`|`tabularx` | ||
|
||
: Use the specified table environment when producing LaTeX output. | ||
The default is [`longtable`] which allows table to spread over multiple tables. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean "over multiple pages"?
MANUAL.txt
Outdated
|
||
: Use the specified table environment when producing LaTeX output. | ||
The default is [`longtable`] which allows table to spread over multiple tables. | ||
[`tabularx`] allows for columns which autospread over the entire linewidth. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't sure exactly what was meant by "autospread over the entire linewidth."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe taking from the description of the ctan package:
" [tabularx
] allows for paragraph-like columns whose width automatically expand to fill the width of the environment"
Sorry, I just haven't had time to review it. Can you say more about the motivation for the change? |
One motivation from my perspective is that In my case, this happily pushes sections into the bottom margin and the space between pages, so they are lost. This is a known bug in |
Could this be moved along? I don't have a workaround for this right now. |
2941904
to
01b9275
Compare
This commit adds a command line switch (`--latex-table-environment`) for switching between possible table environments. Currently pandoc is hardcoded to use `longtable`, which allows for multi-page-tables. This commit adds support for the tabularx environment (allowing columns that span over the while remaining table-width) and gives the possibility to easily add new environments in the future.
01b9275
to
f16e43e
Compare
I updated the documentation according to your Remarks and fixed all merge conflicts. The PR should be mergable again Regarding my motivation: |
|
||
: Use the specified table environment when producing LaTeX output. | ||
The default is [`longtable`] which allows table to spread over multiple pages. | ||
[`tabularx`] allows for paragraph-like columns whose width automatically expand to fill the width of the environment. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lines should be hard-wrapped to fit within 80 columns.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I quite understand this description: "paragraph-like columns whose width automatically expand to fill the width of the environment." Maybe better to say something about what should dictate this choice? For example: If you have long tables that may need to spans multiple pages, use longtable
. If you want to create floating tables (and for better compatibility with other floating elements on the page), use tabularx
.
@@ -1599,6 +1607,10 @@ LaTeX variables are used when [creating a PDF]. | |||
supports 'plain' (default), 'empty', and 'headings'; headings puts | |||
section titles in the header. | |||
|
|||
`table_environment` | |||
: The environemnt given by `--latex-table-environment` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"environment"
@@ -850,6 +850,17 @@ options = | |||
UTF8.hPutStr stdout (usageMessage prg options) | |||
exitSuccess )) | |||
"" -- "Show help" | |||
, Option "" ["latex-table-class"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be latex-table-environment
, given the documentation? (also elsewhere)
@@ -168,6 +169,11 @@ data ReferenceLocation = EndOfBlock -- ^ End of block | |||
| EndOfDocument -- ^ at end of document | |||
deriving (Show, Read, Eq, Data, Typeable, Generic) | |||
|
|||
-- | Class of tables to use in LaTeX output | |||
data LatexTableEnvironment = Longtable -- ^ Use longtable for tables | |||
| Tabularx -- ^ Use tabularx tables |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should align as in the other examples in the code.
@@ -204,7 +210,8 @@ data WriterOptions = WriterOptions | |||
, writerReferenceLocation :: ReferenceLocation -- ^ Location of footnotes and references for writing markdown | |||
, writerSyntaxMap :: SyntaxMap | |||
, writerPreferAscii :: Bool -- ^ Prefer ASCII representations of characters when possible | |||
} deriving (Show, Data, Typeable, Generic) | |||
, writerLatexTableEnvironment :: LatexTableEnvironment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note clearly the API change in the commit comment.
case align of | ||
AlignLeft -> "l" | ||
AlignRight -> "r" | ||
AlignCenter -> "c" | ||
AlignDefault -> "l" | ||
AlignDefault -> if index == 0 then "l" else "X" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is "l" used for the first column and then "X"?
Thanks for the update. I've made some comments to your patch. Currently there are no tests. There should be tests. Also, your patch assumes that the only differences between the environments lie in the column specs and environment name. Have you tested things like captions, footnotes in table cells, and so on, to make sure that this is the case? |
Wouldn't it make sense to use tabu instead of
Tabu is very much compatible with longtable as far as the table contents go. Like New syntax spitballingIf you wanted to add syntax for column stretching, I have some suggestions. I guess a solution that relies on the number of leading or trailing dashes is Hence, adding another character to the Style 1:
def. aligned reg. RA reg. str. LA str. RA str. CA reg. LA
----------------- -------- -------* *------- *-------* ----------
1 2 3 4 5 6
7 8 9 10 11 12 Style 2:
def. aligned reg. RA reg. str. LA str. RA str. CA reg. LA
----------------- -------- -------* -------* --------* ----------
1 2 3 4 5 6
7 8 9 10 11 12 Similar syntax could be used for other types of tables. I could try to think New syntax or no, I believe that this extension to the syntax would bring value to users |
tabu scared me off with this note in the documentation:
… The tabu package patches internal commands of many packages and is liable to stop working if those internal interfaces change. Unfortunately the original author appears to be out of contact and the package had not been updated for some years.
|
I would prefer longtabu as well instead of longtable. The definition of longtabu is close to longtable and I guess it is not a big deal to add it with a optional argument to pandoc. The tabu packge is still working well :). With longtabu automatic linebreaks in a cell are possible due to the column X definition which would be a benifit for pandoc. |
This PR adds a command line switch (
--latex-table-environment
) for switching between possible table environments. Currently pandoc is hardcoded to uselongtable
, which allows for multi-page-tables. This adds support for the tabularx environment (allowing columns that span over the while remaining table-width) and gives the possibility to easily add new environments in the future.NOTE: The package used in the template could also be
ltablex
, which is a combination of longtable and tabularx (allows multi-page tables with auto-spanning columns).