JensErat / pandoc-scrlttr2

Writing Letters in Markdown Using Pandoc and KOMA-Script
61 stars 22 forks source link

table trouble #22

Open korakinos opened 1 year ago

korakinos commented 1 year ago

I'm having trouble putting a table in a pandoc-scrlttr2 document (using pandoc 2.18). I'm documenting it here in case somebody has an idea for a fix or can clarify whether one is even possible.

Anyway, here is a small example:

---
letteroption:
- DIN          # typeset following DIN norm
to: |          # required, YAML multiline value
  Maurice Moss  
  Reynholm Industries  
  123 Carenden Road  
  LONDON  
  EC5M 8AJ  
  GREAT BRITAIN
lang: en
subject: Lorem Ipsum
opening: Dear Moss,
closing: Sincerely,
...

+---+---+
| a | b |
+===+===+
| c | d |
+---+---+

Here is a pandoc command to compile a pdf and its output:

$  pandoc --output=temp.pdf temp.md --template scrlttr2 
Error producing PDF.
! Undefined control sequence.
<argument> @{} >{\raggedright \arraybackslash 
                                              }p{(\columnwidth - 2\tabcolsep...
l.125 ...width - 2\tabcolsep) * \real{0.0556}}@{}}

Looking at the generated latex code, I see that it uses longtable. Possibly longtable is not compatible with scrlttr2?

\documentclass[english,]{scrlttr2}
\usepackage{lmodern}
\usepackage{amssymb,amsmath}
\usepackage{ifxetex,ifluatex}
\usepackage{fixltx2e} % provides \textsubscript
\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
  \usepackage[T1]{fontenc}
  \usepackage[utf8]{inputenc}
\else % if luatex or xelatex
  \ifxetex
    \usepackage{mathspec}
  \else
    \usepackage{fontspec}
  \fi
  \defaultfontfeatures{Ligatures=TeX,Scale=MatchLowercase}
\fi
% use upquote if available, for straight quotes in verbatim environments
\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
% use microtype if available
\IfFileExists{microtype.sty}{%
\usepackage{microtype}
\UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts
}{}
\usepackage{hyperref}
\hypersetup{unicode=true,
            pdfborder={0 0 0},
            breaklinks=true}
\urlstyle{same}  % don't use monospace font for urls
\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
  \usepackage[shorthands=off,main=english]{babel}
\else
  \usepackage{polyglossia}
  \setmainlanguage[]{}
\fi
\usepackage{longtable,booktabs}
\IfFileExists{parskip.sty}{%
\usepackage{parskip}
}{% else
\setlength{\parindent}{0pt}
\setlength{\parskip}{6pt plus 2pt minus 1pt}
}
\setlength{\emergencystretch}{3em}  % prevent overfull lines
\providecommand{\tightlist}{%
  \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
\setcounter{secnumdepth}{0}
% Redefines (sub)paragraphs to behave more like sections
\ifx\paragraph\undefined\else
\let\oldparagraph\paragraph
\renewcommand{\paragraph}[1]{\oldparagraph{#1}\mbox{}}
\fi
\ifx\subparagraph\undefined\else
\let\oldsubparagraph\subparagraph
\renewcommand{\subparagraph}[1]{\oldsubparagraph{#1}\mbox{}}
\fi

% Only set \date if defined, otherwise scrlttr2 will use the current date

\newkomavar{opening}
\newkomavar{closing}

% Default to disabled fields, can be overridden by setting pandoc variables or .lco files
\KOMAoptions{fromemail=false}
\KOMAoptions{fromfax=false}
\KOMAoptions{fromlogo=false}
\KOMAoptions{frommobilephone=false}
\KOMAoptions{fromphone=false}
\KOMAoptions{fromurl=false}
\KOMAoptions{fromalign=right}

\LoadLetterOption{DIN}

\setkomavar{subject}{Lorem Ipsum}

\setkomavar{opening}{Dear Moss,}
\setkomavar{closing}{Sincerely,}

\begin{document}

\begin{letter}{%
Maurice Moss\\
Reynholm Industries\\
123 Carenden Road\\
LONDON\\
EC5M 8AJ\\
GREAT BRITAIN
}

\opening{\usekomavar{opening}}

\begin{longtable}[]{@{}
  >{\raggedright\arraybackslash}p{(\columnwidth - 2\tabcolsep) * \real{0.0556}}
  >{\raggedright\arraybackslash}p{(\columnwidth - 2\tabcolsep) * \real{0.0556}}@{}}
\toprule()
\begin{minipage}[b]{\linewidth}\raggedright
a
\end{minipage} & \begin{minipage}[b]{\linewidth}\raggedright
b
\end{minipage} \\
\midrule()
\endhead
c & d \\
\bottomrule()
\end{longtable}

\closing{\usekomavar{closing}}

\end{letter}
\end{document}
twsh commented 1 year ago

I am using Pandoc 2.17.1.1 and a version of the the template in this repo which I merged with the default template for that version of Pandoc: gist.github.com/twsh/dd7864f99d168695d6d0273ecd9d9570. The table works fine for me with that setup. Maybe that will at least help you to isolate your problem? It at least suggests that longtable can work with scrlttr2.