Hi there,
Basically I'm trying to set different line spacings for the general document on one hand and for tables on the other hand. The motivation is that I want to have a general line spacing of 1.5, but that doesn't look good in tables which have multiline cells (and makes them unncecessary long). So I'm trying to set a different line spacing for the tables only. Currently I'm inserting the following Latex commands before a table and wrapping this in a Latex group to only affect the table by the commands:
\begingroup
\singlespace
\renewcommand*{\arraystretch}{1.5}
... here would come the table ...
\endgroup
Now the problem is that if the table is placed at the very end of the page or spans over mulitple pages the headers and footers of those pages are affected by the
\singlespace and \renewcommand*{\arraystretch}{1.5}
commands above.
I have created the following Markdown document as a minimal working example to demostrate the problem:
---
documentclass: scrreprt
linestretch: 1.5
header-includes:
- \pagestyle{headings}
- \usepackage{scrlayer-scrpage}
- \KOMAoptions{headsepline = on}
- \KOMAoptions{footsepline = on}
- \addtokomafont{pageheadfoot}{\normalfont\small}
- \addtokomafont{pagenumber}{\small}
- \ModifyLayer[addvoffset = 3pt]{scrheadings.head.below.line}
- \ModifyLayer[addvoffset = 3pt]{plain.scrheadings.head.below.line}
---
# Test Document
_Nothing more here, go to the following pages..._
\newpage
This is a page to demonstrate correct header/footer layout.
\newpage
On this page the header/footer layout is messed up because of the table below.
\begingroup
\singlespace
\renewcommand*{\arraystretch}{1.5}
| Right | Left | Default | Center | Multi-line column |
|------:|:-----|---------|:------:| ----------------- |
| 123 | 123 | 123 | 123 | Some random text that doesn't fit on a single line because it consists of way tooooooooooo many characters |
| 123 | 123 | 123 | 123 | Some random text that doesn't fit on a single line because it consists of way tooooooooooo many characters |
| 123 | 123 | 123 | 123 | Some random text that doesn't fit on a single line because it consists of way tooooooooooo many characters |
| 123 | 123 | 123 | 123 | Some random text that doesn't fit on a single line because it consists of way tooooooooooo many characters |
| 123 | 123 | 123 | 123 | Some random text that doesn't fit on a single line because it consists of way tooooooooooo many characters |
| 123 | 123 | 123 | 123 | Some random text that doesn't fit on a single line because it consists of way tooooooooooo many characters |
| 123 | 123 | 123 | 123 | Some random text that doesn't fit on a single line because it consists of way tooooooooooo many characters |
| 123 | 123 | 123 | 123 | Some random text that doesn't fit on a single line because it consists of way tooooooooooo many characters |
| 123 | 123 | 123 | 123 | Some random text that doesn't fit on a single line because it consists of way tooooooooooo many characters |
| 123 | 123 | 123 | 123 | Some random text that doesn't fit on a single line because it consists of way tooooooooooo many characters |
: Test Table
\endgroup
On this page the header/footer is fine again because the page doesn't end with a table.
A simpler
header-includes key would consist of only the following which demonstrates the problem as well, but in a less visible manner since only the header is affected then:
header-includes:
- \pagestyle{headings}
- \KOMAoptions{headsepline = on}
I've attached the MVE Markdown and the PDF produced with
pandoc --output=test_document_2.pdf test_document_2.md to this post.
My questions now include:
- Is there a better way to change the line spacing in tables that doesn't affect the rest of the document layout (ideally something I could define in the header-includes key)?
- Or alternatively, can I add something to avoid the misplaced headers/footers to the example above?