Consider the following quarto
document:
JavaScript
x
31
31
1
---
2
title: "Some title"
3
author: X
4
date: "2022"
5
format:
6
pdf:
7
number-sections: true
8
fontsize: 12 pt
9
papersize: A4
10
fig-pos: 'H'
11
geometry: "left=2.54cm,right=2.54cm,top=2.54cm,bottom=2.54cm"
12
include-in-header:
13
text: |
14
usepackage[font=small]{caption}
15
usepackage{float}
16
usepackage[table]{xcolor}
17
18
engine: jupyter
19
jupyter: r-reticulate
20
---
21
22
begin{center}
23
begin{tabular}{|c|c|}
24
hline
25
1 & 2tabularnewline
26
hline
27
cellcolor{blue} 3 & cellcolor{red} 4tabularnewline
28
hline
29
end{tabular}
30
end{center}
31
I get the following error, when rendering it:
JavaScript
1
9
1
LaTeX Error: Option clash for package xcolor.
2
3
See the LaTeX manual or LaTeX Companion for explanation.
4
Type H <return> for immediate help.
5
6
7
l.83 KOMAoption
8
{captions}{tableheading}
9
A solution that works is to add table
to the following line of the tex
file generated by quarto
:
JavaScript
1
2
1
PassOptionsToPackage{dvipsnames,svgnames,x11names}{xcolor}
2
That is:
JavaScript
1
2
1
PassOptionsToPackage{dvipsnames,svgnames,x11names, table}{xcolor}
2
My question is: How can I do that from inside the quarto
document instead of hacking the tex
file?
Advertisement
Answer
As explained in this answer on Tex StackExchange, one possible solution could be passing table
as a classoption
and you do not need to declare using xcolor
explicitly since it is used by-default.
JavaScript
1
28
28
1
---
2
title: "Some title"
3
author: X
4
date: "2022"
5
format:
6
pdf:
7
number-sections: true
8
fontsize: 12 pt
9
papersize: A4
10
fig-pos: 'H'
11
geometry: "left=2.54cm,right=2.54cm,top=2.54cm,bottom=2.54cm"
12
classoption: table
13
include-in-header:
14
text: |
15
usepackage[font=small]{caption}
16
usepackage{float}
17
---
18
19
begin{center}
20
begin{tabular}{|c|c|}
21
hline
22
1 & 2tabularnewline
23
hline
24
cellcolor{blue} 3 & cellcolor{red} 4tabularnewline
25
hline
26
end{tabular}
27
end{center}
28