Pandoc version: 2.9.2.1
Eisvogel template version: 2.5.0
Note: I asked this question on tex.stackexchange.com and was referred here for the larger pandoc community.
Looking for how to change the font size for tables in the eisvogel template used with pandoc to generate PDF from Markdown.
I have my Markdown file with a table in it but would like to reduce the font size in the table.
Here is how pandoc is being executed –
#!/bin/bash
MARKDOWN_FILE=$1
PDF_FILE=$(basename $MARKDOWN_FILE .md).pdf
pandoc $MARKDOWN_FILE
--standalone
--template eisvogel
--listings
--variable listings-disable-line-numbers=true
--variable code-block-font-size=\scriptsize
--variable table-use-row-colors=true
--variable geometry:margin=1in
--variable linkcolor=blue
--output $PDF_FILE
The variable settings table-use-row-colors and code-block-font-size=scriptsize are working as expected but I have not been able to find a way to reduce the font size for the table.
In case it’s not obvious my tex/latex skills are minimal. 🙂
Here is a minimum working example Markdown document with the font size of the code block reduced from small to scriptsize as desired but can’t figure out how to reduce the table font size –
# MWE - minimum working example
MWE illustrating code block and table font size adjustments.
Here is a code block -
my
code
block
And here is a table -
| col1 | col2 | col3 |
|:-----:|--------------------------|------------------------------------------------|
| 10 | `ten` | row 1 text |
| 11 | `eleven` | row 2 text |
| 12 | `twelve` | row 3 text |
Here is the generated .tex –
%%
% Copyright (c) 2017 - 2024, Pascal Wagler;
% Copyright (c) 2014 - 2024, John MacFarlane
%
% All rights reserved.
%
% Redistribution and use in source and binary forms, with or without
% modification, are permitted provided that the following conditions
% are met:
%
% - Redistributions of source code must retain the above copyright
% notice, this list of conditions and the following disclaimer.
%
% - Redistributions in binary form must reproduce the above copyright
% notice, this list of conditions and the following disclaimer in the
% documentation and/or other materials provided with the distribution.
%
% - Neither the name of John MacFarlane nor the names of other
% contributors may be used to endorse or promote products derived
% from this software without specific prior written permission.
%
% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
% "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
% LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
% FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
% COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
% INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
% BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
% LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
% CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
% LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
% ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
% POSSIBILITY OF SUCH DAMAGE.
%%
%%
% This is the Eisvogel pandoc LaTeX template.
%
% For usage information and examples visit the official GitHub page:
% https://github.com/Wandmalfarbe/pandoc-latex-template
%%
% Options for packages loaded elsewhere
PassOptionsToPackage{unicode}{hyperref}
PassOptionsToPackage{hyphens}{url}
PassOptionsToPackage{dvipsnames,svgnames,x11names,table}{xcolor}
%
documentclass[
paper=a4,
,captions=tableheading
]{scrartcl}
usepackage{amsmath,amssymb}
% Use setspace anyway because we change the default line spacing.
% The spacing is changed early to affect the titlepage and the TOC.
usepackage{setspace}
setstretch{1.2}
usepackage{iftex}
ifPDFTeX
usepackage[T1]{fontenc}
usepackage[utf8]{inputenc}
usepackage{textcomp} % provide euro and other symbols
else % if luatex or xetex
usepackage{unicode-math} % this also loads fontspec
defaultfontfeatures{Scale=MatchLowercase}
defaultfontfeatures[rmfamily]{Ligatures=TeX,Scale=1}
fi
usepackage{lmodern}
ifPDFTeXelse
% xetex/luatex font selection
fi
% Use upquote if available, for straight quotes in verbatim environments
IfFileExists{upquote.sty}{usepackage{upquote}}{}
IfFileExists{microtype.sty}{% use microtype if available
usepackage[]{microtype}
UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts
}{}
makeatletter
@ifundefined{KOMAClassName}{% if non-KOMA class
IfFileExists{parskip.sty}{%
usepackage{parskip}
}{% else
setlength{parindent}{0pt}
setlength{parskip}{6pt plus 2pt minus 1pt}}
}{% if KOMA class
KOMAoptions{parskip=half}}
makeatother
usepackage{xcolor}
definecolor{default-linkcolor}{HTML}{A50000}
definecolor{default-filecolor}{HTML}{A50000}
definecolor{default-citecolor}{HTML}{4077C0}
definecolor{default-urlcolor}{HTML}{4077C0}
usepackage[margin=1in]{geometry}
usepackage{listings}
newcommand{passthrough}[1]{#1}
lstset{defaultdialect=[5.3]Lua}
lstset{defaultdialect=[x86masm]Assembler}
usepackage{longtable,booktabs,array}
usepackage{calc} % for calculating minipage widths
% Correct order of tables after paragraph or subparagraph
usepackage{etoolbox}
makeatletter
patchcmdlongtable{par}{if@noskipsecmbox{}fipar}{}{}
makeatother
% Allow footnotes in longtable head/foot
IfFileExists{footnotehyper.sty}{usepackage{footnotehyper}}{usepackage{footnote}}
makesavenoteenv{longtable}
% add backlinks to footnote references, cf. https://tex.stackexchange.com/questions/302266/make-footnote-clickable-both-ways
usepackage{footnotebackref}
setlength{emergencystretch}{3em} % prevent overfull lines
providecommand{tightlist}{%
setlength{itemsep}{0pt}setlength{parskip}{0pt}}
setcounter{secnumdepth}{-maxdimen} % remove section numbering
usepackage{bookmark}
IfFileExists{xurl.sty}{usepackage{xurl}}{} % add URL line breaks if available
urlstyle{same}
hypersetup{
colorlinks=true,
linkcolor={blue},
filecolor={default-filecolor},
citecolor={default-citecolor},
urlcolor={default-urlcolor},
breaklinks=true,
pdfcreator={LaTeX via pandoc with the Eisvogel template}}
author{}
date{}
%%
%% added
%%
%
% for the background color of the title page
%
%
% break urls
%
PassOptionsToPackage{hyphens}{url}
%
% When using babel or polyglossia with biblatex, loading csquotes is recommended
% to ensure that quoted texts are typeset according to the rules of your main language.
%
usepackage{csquotes}
%
% captions
%
definecolor{caption-color}{HTML}{777777}
usepackage[font={stretch=1.2}, textfont={color=caption-color}, position=top, skip=4mm, labelfont=bf, singlelinecheck=false, justification=raggedright]{caption}
setcapindent{0em}
%
% blockquote
%
definecolor{blockquote-border}{RGB}{221,221,221}
definecolor{blockquote-text}{RGB}{119,119,119}
usepackage{mdframed}
newmdenv[rightline=false,bottomline=false,topline=false,linewidth=3pt,linecolor=blockquote-border,skipabove=parskip]{customblockquote}
renewenvironment{quote}{begin{customblockquote}list{}{rightmargin=0emleftmargin=0em}%
itemrelaxcolor{blockquote-text}ignorespaces}{unskipunskipendlistend{customblockquote}}
%
% Source Sans Pro as the default font family
% Source Code Pro for monospace text
%
% 'default' option sets the default
% font family to Source Sans Pro, not sfdefault.
%
ifnum 0ifxetex 1fiifluatex 1fi=0 % if pdftex
usepackage[default]{sourcesanspro}
usepackage{sourcecodepro}
else % if not pdftex
usepackage[default]{sourcesanspro}
usepackage{sourcecodepro}
% XeLaTeX specific adjustments for straight quotes: https://tex.stackexchange.com/a/354887
% This issue is already fixed (see https://github.com/silkeh/latex-sourcecodepro/pull/5) but the
% fix is still unreleased.
% TODO: Remove this workaround when the new version of sourcecodepro is released on CTAN.
ifxetex
makeatletter
defaultfontfeatures[ttfamily]
{ Numbers = sourcecodepro@figurestyle,
Scale = SourceCodePro@scale,
Extension = .otf }
setmonofont
[ UprightFont = *-sourcecodepro@regstyle,
ItalicFont = *-sourcecodepro@regstyle It,
BoldFont = *-sourcecodepro@boldstyle,
BoldItalicFont = *-sourcecodepro@boldstyle It ]
{SourceCodePro}
makeatother
fi
fi
%
% heading color
%
definecolor{heading-color}{RGB}{40,40,40}
addtokomafont{section}{color{heading-color}}
% When using the classes report, scrreprt, book,
% scrbook or memoir, uncomment the following line.
%addtokomafont{chapter}{color{heading-color}}
%
% variables for title, author and date
%
usepackage{titling}
title{}
author{}
date{}
%
% tables
%
definecolor{table-row-color}{HTML}{F5F5F5}
definecolor{table-rule-color}{HTML}{999999}
%arrayrulecolor{black!40}
arrayrulecolor{table-rule-color} % color of toprule, midrule, bottomrule
setlengthheavyrulewidth{0.3ex} % thickness of toprule, bottomrule
renewcommand{arraystretch}{1.3} % spacing (padding)
% Unfortunately the colored cells extend beyond the edge of the
% table because pandoc uses @-expressions (@{}) like so:
%
% begin{longtable}[]{@{}ll@{}}
% end{longtable}
%
% https://en.wikibooks.org/wiki/LaTeX/Tables#.40-expressions
usepackage{etoolbox}
AtBeginEnvironment{longtable}{rowcolors{2}{}{table-row-color!100}}
preto{toprule}{hiderowcolors}{}{}
appto{endhead}{showrowcolors}{}{}
appto{endfirsthead}{showrowcolors}{}{}
%
% remove paragraph indentation
%
setlength{parindent}{0pt}
setlength{parskip}{6pt plus 2pt minus 1pt}
setlength{emergencystretch}{3em} % prevent overfull lines
%
%
% Listings
%
%
%
% general listing colors
%
definecolor{listing-background}{HTML}{F7F7F7}
definecolor{listing-rule}{HTML}{B3B2B3}
definecolor{listing-numbers}{HTML}{B3B2B3}
definecolor{listing-text-color}{HTML}{000000}
definecolor{listing-keyword}{HTML}{435489}
definecolor{listing-keyword-2}{HTML}{1284CA} % additional keywords
definecolor{listing-keyword-3}{HTML}{9137CB} % additional keywords
definecolor{listing-identifier}{HTML}{435489}
definecolor{listing-string}{HTML}{00999A}
definecolor{listing-comment}{HTML}{8E8E8E}
lstdefinestyle{eisvogel_listing_style}{
language = java,
xleftmargin = 0.6em,
framexleftmargin = 0.4em,
backgroundcolor = color{listing-background},
basicstyle = color{listing-text-color}linespread{1.0}%
lst@ifdisplaystyle%
footnotesize%
fittfamily{},
breaklines = true,
frame = single,
framesep = 0.19em,
rulecolor = color{listing-rule},
frameround = ffff,
tabsize = 4,
numberstyle = color{listing-numbers},
aboveskip = 1.0em,
belowskip = 0.1em,
abovecaptionskip = 0em,
belowcaptionskip = 1.0em,
keywordstyle = {color{listing-keyword}bfseries},
keywordstyle = {[2]color{listing-keyword-2}bfseries},
keywordstyle = {[3]color{listing-keyword-3}bfseriesitshape},
sensitive = true,
identifierstyle = color{listing-identifier},
commentstyle = color{listing-comment},
stringstyle = color{listing-string},
showstringspaces = false,
escapeinside = {/*@}{@*/}, % Allow LaTeX inside these special comments
literate =
{á}{{'a}}1 {é}{{'e}}1 {í}{{'i}}1 {ó}{{'o}}1 {ú}{{'u}}1
{Á}{{'A}}1 {É}{{'E}}1 {Í}{{'I}}1 {Ó}{{'O}}1 {Ú}{{'U}}1
{à}{{`a}}1 {è}{{`e}}1 {ì}{{`i}}1 {ò}{{`o}}1 {ù}{{`u}}1
{À}{{`A}}1 {È}{{`E}}1 {Ì}{{`I}}1 {Ò}{{`O}}1 {Ù}{{`U}}1
{ä}{{"a}}1 {ë}{{"e}}1 {ï}{{"i}}1 {ö}{{"o}}1 {ü}{{"u}}1
{Ä}{{"A}}1 {Ë}{{"E}}1 {Ï}{{"I}}1 {Ö}{{"O}}1 {Ü}{{"U}}1
{â}{{^a}}1 {ê}{{^e}}1 {î}{{^i}}1 {ô}{{^o}}1 {û}{{^u}}1
{Â}{{^A}}1 {Ê}{{^E}}1 {Î}{{^I}}1 {Ô}{{^O}}1 {Û}{{^U}}1
{œ}{{oe}}1 {Œ}{{OE}}1 {æ}{{ae}}1 {Æ}{{AE}}1 {ß}{{ss}}1
{ç}{{c c}}1 {Ç}{{c C}}1 {ø}{{o}}1 {å}{{r a}}1 {Å}{{r A}}1
{€}{{EUR}}1 {£}{{pounds}}1 {«}{{guillemotleft}}1
{»}{{guillemotright}}1 {ñ}{{~n}}1 {Ñ}{{~N}}1 {¿}{{?`}}1
{…}{{ldots}}1 {≥}{{>=}}1 {≤}{{<=}}1 {„}{{glqq}}1 {“}{{grqq}}1
{ΓÇ¥}{{''}}1
}
lstset{style=eisvogel_listing_style}
%
% Java (Java SE 12, 2019-06-22)
%
lstdefinelanguage{Java}{
morekeywords={
% normal keywords (without data types)
abstract,assert,break,case,catch,class,continue,default,
do,else,enum,exports,extends,final,finally,for,if,implements,
import,instanceof,interface,module,native,new,package,private,
protected,public,requires,return,static,strictfp,super,switch,
synchronized,this,throw,throws,transient,try,volatile,while,
% var is an identifier
var
},
morekeywords={[2] % data types
% primitive data types
boolean,byte,char,double,float,int,long,short,
% String
String,
% primitive wrapper types
Boolean,Byte,Character,Double,Float,Integer,Long,Short
% number types
Number,AtomicInteger,AtomicLong,BigDecimal,BigInteger,DoubleAccumulator,DoubleAdder,LongAccumulator,LongAdder,Short,
% other
Object,Void,void
},
morekeywords={[3] % literals
% reserved words for literal values
null,true,false,
},
sensitive,
morecomment = [l]//,
morecomment = [s]{/*}{*/},
morecomment = [s]{/**}{*/},
morestring = [b]",
morestring = [b]',
}
lstdefinelanguage{XML}{
morestring = [b]",
moredelim = [s][bfseriescolor{listing-keyword}]{<}{ },
moredelim = [s][bfseriescolor{listing-keyword}]{</}{>},
moredelim = [l][bfseriescolor{listing-keyword}]{/>},
moredelim = [l][bfseriescolor{listing-keyword}]{>},
morecomment = [s]{<?}{?>},
morecomment = [s]{<!--}{-->},
commentstyle = color{listing-comment},
stringstyle = color{listing-string},
identifierstyle = color{listing-identifier}
}
%
% header and footer
%
usepackage[headsepline,footsepline]{scrlayer-scrpage}
newpairofpagestyles{eisvogel-header-footer}{
clearpairofpagestyles
ihead*{}
chead*{}
ohead*{}
ifoot*{}
cfoot*{}
ofoot*{thepage}
addtokomafont{pageheadfoot}{upshape}
}
pagestyle{eisvogel-header-footer}
%%
%% end added
%%
begin{document}
%%
%% begin titlepage
%%
%%
%% end titlepage
%%
hypertarget{mwe---minimum-working-example}{%
section{MWE - minimum working
example}label{mwe---minimum-working-example}}
MWE illustrating code block and table font size adjustments.
Here is a code block -
begin{lstlisting}
my
code
block
end{lstlisting}
And here is a table -
begin{longtable}[]{@{}cll@{}}
toprule
col1 & col2 & col3tabularnewline
midrule
endhead
10 & passthrough{lstinline!ten!} & row 1 texttabularnewline
11 & passthrough{lstinline!eleven!} & row 2 texttabularnewline
12 & passthrough{lstinline!twelve!} & row 3 texttabularnewline
bottomrule
end{longtable}
end{document}
5