Advertisements
Consider the following quarto
document:
---
title: "Some title"
author: X
date: "2022"
format:
pdf:
number-sections: true
fontsize: 12 pt
papersize: A4
fig-pos: 'H'
geometry: "left=2.54cm,right=2.54cm,top=2.54cm,bottom=2.54cm"
include-in-header:
text: |
\usepackage[font=small]{caption}
\usepackage{float}
\usepackage[table]{xcolor}
engine: jupyter
jupyter: r-reticulate
---
\begin{center}
\begin{tabular}{|c|c|}
\hline
1 & 2\tabularnewline
\hline
\cellcolor{blue} 3 & \cellcolor{red} 4\tabularnewline
\hline
\end{tabular}
\end{center}
I get the following error, when rendering it:
LaTeX Error: Option clash for package xcolor.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.83 \KOMAoption
{captions}{tableheading}
A solution that works is to add table
to the following line of the tex
file generated by quarto
:
\PassOptionsToPackage{dvipsnames,svgnames,x11names}{xcolor}
That is:
\PassOptionsToPackage{dvipsnames,svgnames,x11names, table}{xcolor}
My question is: How can I do that from inside the quarto
document instead of hacking the tex
file?
>Solution :
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.
---
title: "Some title"
author: X
date: "2022"
format:
pdf:
number-sections: true
fontsize: 12 pt
papersize: A4
fig-pos: 'H'
geometry: "left=2.54cm,right=2.54cm,top=2.54cm,bottom=2.54cm"
classoption: table
include-in-header:
text: |
\usepackage[font=small]{caption}
\usepackage{float}
---
\begin{center}
\begin{tabular}{|c|c|}
\hline
1 & 2\tabularnewline
\hline
\cellcolor{blue} 3 & \cellcolor{red} 4\tabularnewline
\hline
\end{tabular}
\end{center}