I am wondering why the first caption of the first table will not be displayed correctly, if I use the following code-order (full MWE below):
\usepackage{xcolor}% mark text %must be above arydshln
\usepackage{colortbl}
\usepackage{arydshln}% draw dash-lines in tables
\usepackage{array,booktabs,makecell,multirow,subcaption,xltabular}
\setcellgapes{2pt}
\newcolumntype{L}{>{\raggedright\arraybackslash}X}
\newcolumntype{P}[1]{>{\raggedleft\arraybackslash}p{#1}}
\renewcommand{\arraystretch}{1.5}
\setlength\tabcolsep{4pt} % default: 6pt
%\usepackage[table]{xcolor}
\setlength\dashlinedash{0.2pt}% dashed lines
\setlength\dashlinegap{1.5pt}% dashed lines
\setlength\arrayrulewidth{0.3pt}% dashed lines
\arrayrulecolor{gray}
\usepackage{diagbox}% diagonal box
\usepackage{tikz}% tikz
\usetikzlibrary{arrows.meta,decorations.pathmorphing,backgrounds,fit,positioning,shapes.symbols,chains}
If I set it up like this, the caption gets aligned to the right (but only for the first table somehow):
I have spent hours now moving the packages around, as for some reason if I run the MWE in Overleaf I can fix the alignment if I don't use
\usepackage{xcolor}
\usepackage{colortbl}
in the beginning, but \usepackage[table]{xcolor}
below \usepackage{arydshln}
(so basically this order:)
\usepackage{arydshln}% draw dash-lines in tables
\usepackage{array,booktabs,makecell,multirow,subcaption,xltabular}
\setcellgapes{2pt}
\newcolumntype{L}{>{\raggedright\arraybackslash}X}
\newcolumntype{P}[1]{>{\raggedleft\arraybackslash}p{#1}}
\renewcommand{\arraystretch}{1.5}
\setlength\tabcolsep{4pt} % default: 6pt
\usepackage[table]{xcolor}
\setlength\dashlinedash{0.2pt}% dashed lines
\setlength\dashlinegap{1.5pt}% dashed lines
\setlength\arrayrulewidth{0.3pt}% dashed lines
\arrayrulecolor{gray}
However, if I run the exact same MWE on my Macbook (TexShop) (not Overleaf) I receive the following error:
(/usr/local/texlive/2020/texmf-dist/tex/latex/tools/tabularx.sty Package: tabularx 2020/01/15 v2.11c `tabularx' package (DPC) \TX@col@width=\dimen349 \TX@old@table=\dimen350 \TX@old@col=\dimen351 \TX@target=\dimen352 \TX@delta=\dimen353 \TX@cols=\count447 \TX@ftn=\toks80 ) (/usr/local/texlive/2020/texmf-dist/tex/latex/ltablex/ltablex.sty Package: ltablex 2014/08/13 v1.1 Modified tabularx )) ! LaTeX Error: Option clash for package xcolor. (see the LaTeX manual...) l.141 \setlength \dashlinedash{0.2pt}% dashed lines
So I don't seem to be able to use the 2nd order with \usepackage[table]{xcolor}
.
If I add [table] as a condition to the first line and run the code, it will clash with colortbl
package.
Since I have my whole setup on Mac (and only use Overleaf for crosstesting), it would be very cool, if I found a way to make it run on Mac without disalignment.
(I am trying to finish my thesis, but have been spending days now on tables and trying to please the xcolor package that is quite a sensitive package T_T)
MWE running on Mac (with wrong caption alignment):
%----------------------------------------------------------------------------
% COMPILING SORTING
%----------------------------------------------------------------------------
% arara: lualatex: { shell: true, synctex: true }
%----------------------------------------------------------------------------
% LAYOUT
%----------------------------------------------------------------------------
\documentclass[
12pt,
a4paper,
headings=standardclasses,
listof=totoc,
numbers=noenddot
]{scrartcl}
\usepackage[hmargin=2.5cm, top=2.5cm, bottom=2cm, footskip=1cm]{geometry}
\usepackage[onehalfspacing]{setspace}
\usepackage[main=ngerman, english]{babel}
%----------------------------------------------------------------------------
% FONT
%----------------------------------------------------------------------------
\usepackage{libertine}
\usepackage{libertinust1math}
\usepackage[match]{luatexja-preset}% Japanese
\ltjsetparameter{jacharrange={-3}}% punctuation is Latin
% tables sffamily
\usepackage{etoolbox}
\AtBeginEnvironment{xltabular}{\sffamily}% xltabular
\usepackage{floatrow}
\floatsetup[table]{font=sf,capposition=top}% table
% caption sffamily
\usepackage{caption}
\captionsetup[table]{labelfont=sf,font=sf}
%----------------------------------------------------------------------------
% TABLES
%----------------------------------------------------------------------------
\usepackage{xcolor}% mark text must be above arydshln
\usepackage{colortbl}
\usepackage{arydshln}% draw dash-lines in tables
\usepackage{array,booktabs,makecell,multirow,subcaption,xltabular}
\setcellgapes{2pt}
\newcolumntype{L}{>{\raggedright\arraybackslash}X}
\newcolumntype{P}[1]{>{\raggedleft\arraybackslash}p{#1}}
\renewcommand{\arraystretch}{1.5}
\setlength\tabcolsep{4pt} % default: 6pt
%\usepackage[table]{xcolor}
\setlength\dashlinedash{0.2pt}% dashed lines
\setlength\dashlinegap{1.5pt}% dashed lines
\setlength\arrayrulewidth{0.3pt}% dashed lines
\arrayrulecolor{gray}
%----------------------------------------------------------------------------
% MAIN
%----------------------------------------------------------------------------
\usepackage{showframe}
\begin{document}
\begingroup
\setlength\LTleft{0pt}
\setlength\tabcolsep{4pt}% default: 6pt
\makegapedcells
\begin{xltabular}{\textwidth}{lcll}
\caption{Übersicht des historischen Korpus (CHJ) von Chunagon}
\label{ta:choverview}\\
\toprule
\textbf{Epoche}
& \textbf{Periode}
& \textbf{Korpora}
& \textbf{Einordnung} \\
\midrule
\endfirsthead
\caption[]{Übersicht des historischen Korpus (CHJ) von Chunagon \qquad(Fortsetzung)}\\
\toprule
\textbf{Epoche}
& \textbf{Periode}
& \textbf{Korpora}
& \textbf{Einordnung} \\
\midrule
\endhead
\bottomrule
\multicolumn{4}{r}{\small\textit{weiter auf der nächsten Seite}}
\endfoot
\bottomrule
\multicolumn{4}{p{\dimexpr\textwidth-2\tabcolsep}}{\centering
Quelle: CHJ.2009\\
(Eigene Darstellung)}
\endlastfoot
% table body
Altertum & Nara & Man’y\={o}sh\={u} & Gedicht- und Liederanthologie \\
& & Norito & Ritualisierte shint\={o}. Gebete \\
& & Senmy\={o} & Gesetzestexte \\
\addlinespace
& Heian & Monogatari & Fiktive Erzählung (Märchen) \\
& & Nikki & Tagebuchliteratur \\
\addlinespace
\midrule
Mittelalter & Kamakura & Kaid\={o}ki & Reiseliteratur \\
& & Nikki & Tagebuchliteratur \\
& & Zuihitsu & Miszellenliteratur \\
& Muromachi & Ky\={o}gen & Theater-Form \\
& & Kirishitan Shiry\={o} & Christliche Literatur \\
\addlinespace
\midrule
Neuzeit & Edo & Kaid\={o}ki & Reiseliteratur \\
& & Nikki & Tagebuchliteratur \\
& & Zuihitsu & Miszellenliteratur \\
& & Share-bon & Form der Komödie \\
& & Ninj\={o}-bon & Romantische Literatur \\
\addlinespace
\midrule
Moderne & \multirow{2}{*}{\makecell{Meiji\\ Taishō}}
& Zasshi & Zeitschriften \\
& & Ky\={o}kasho & Schulbücher \\
& & Meiji-shoki-k\={o}go Shiry\={o}
& Sammlung gesprochener Sprache \\
& & Kindai sh\={o}setsu & Moderne Romane \\
\end{xltabular}
\endgroup
% -------------------------------------------
% -------------------------------------------
\begingroup
\begin{xltabular}{\linewidth}{ll >{\raggedright}p{2.8cm}L cr}
\caption{Kollokationen von 禍}\\
\toprule
\textbf{Syntax}
& \textbf{Kollokation}
& \textbf{Kana}
& \textbf{Translat}
& \textbf{Freq.}
& \textbf{Score} \\
\midrule
\endfirsthead
\caption[]{Kollokationen von 禍 \qquad(Fortsetzung)}\\
\toprule
\textbf{Syntax}
& \textbf{Kollokation}
& \textbf{Kana}
& \textbf{Translat}
& \textbf{Freq.}
& \textbf{Score} \\
\midrule
\endhead
% \midrule
\multicolumn{6}{r}{\footnotesize\textit{weiter auf der nächsten Seite}}
\endfoot
\bottomrule
\multicolumn{6}{p{\dimexpr\textwidth-2\tabcolsep}}{\centering
Quelle: CHJ.2009\\
(Eigene Darstellung)}
\endlastfoot
\rowcolor{gray!10}
wo + Verb
& & & & 15 & 11,0 \\
& 及ぼす & oyobosu
& ausüben
& 4 & 10,2 \\
\cdashline{2-6}
& 鳥 & tori & Vogel & 2 & 11,1 \\
\cdashline{2-6}
& 洪水 & kōzui & Überschwemmung
& 2 & 10,9 \\
\cdashline{2-6}
& 虫 & mushi & Insekt & 1 & 10,3 \\
\cdashline{2-6}
& 人滿 & & Menschenmenge
& 1 & 10,2 \\
\cdashline{2-6}
& 所謂政教混乱
& iwayuru seikyō konran
& s.\ g.\ politisch-religiöse Verwirrung
& 1 & 10,2 \\
\cdashline{2-6}
& 生民 & seimin & Volk & 1 & 10,2 \\
\cdashline{2-6}
& 子孫赤族
& shison aka-zoku
& Nachkomme der Akha
& 1 & 10,2 \\
\cdashline{2-6}
& 破船 & hasen & Schiffbruch
& 1 & 10,2 \\
\cdashline{2-6}
& 国家党人
& kokka tōjin
& Parteimitglied
& 1 & 10,2 \\
\cdashline{2-6}
& 東夷北狄
& tōi hokuteki
& Dongyi und Beidi (indigene Völker Chinas)
& 1 & 10,2 \\
\cdashline{2-6}
& 連累 & renrui
& Mitschuld & 1 & 10,2 \\
\cdashline{2-6}
& 江浙 & kōnan & Jiangzhe (hist. Region Chinas, ca. 1276--1299)
& 1 & 10,2 \\
\cdashline{2-6}
& 文字 & moji & Schrift (zeichen) & 1 & 10,2 \\
\cdashline{2-6}
& 代々弑殺 & daidai shīsatsu & & 1 & 10,2 \\
\cdashline{2-6}
& 滔天 & tōten & Tōten (pol. Aktivist, 1871--1922) & 1 & 10,1 \\
\cdashline{2-6}
& 宦者 & kanja & Eunuch & 1 & 10,1 \\
\cdashline{2-6}
& 不思議 & fushigi & Mysterium & 1 & 10,1 \\
\cdashline{2-6}
& 先達て & sakidachite & zuvor & 1 & 10,1 \\
\cdashline{2-6}
& 外寇 & gaikō & Invasion & 1 & 10,1 \\
\cdashline{2-6}
& 孛佛兵争 & haifutsu heisō & Deutsch-Französischer Krieg (1870--1871) & 1 & 10,1 \\
\cdashline{2-6}
& 人為 & jin'i & menschliches Tun & 1 & 10,1 \\
\rowcolor{gray!10}
ni + Verb
& & & & 10 & 10,8 \\
& 逢う & au & sich begegnen & 3 & 11,5 \\
\cdashline{2-6}
& 罹る & kakaru & erleiden & 4 & 11,2 \\
\cdashline{2-6}
& 堪ざる & koezaru & (nicht) aushalten & 1 & 10,7 \\
\cdashline{2-6}
& 陥る & ochiiru & in etw. (ver)fallen & 1 & 10,5 \\
\cdashline{2-6}
& 當る & ataru & treffen & 1 & 10,3 \\
\rowcolor{gray!10}
wa + Verb
& & & & 11 & 10,8 \\
& 起こる & okoru & sich ereignen & 4 & 11,9 \\
\cdashline{2-6}
& 伏蔵為る & fukuzō suru & sich verborgen halten & 1 & 10,9 \\
\cdashline{2-6}
& 有る得る & arueru & möglich sein & 1 & 10,8 \\
\cdashline{2-6}
& 局為る & kyokusuru & begrenzen & 1 & 10,8 \\
\cdashline{2-6}
& 及ぶ & oyobu & sich erstrecken & 2 & 10,7 \\
\cdashline{2-6}
& 避ける & sakeru & (ver)meiden & 1 & 10,5 \\
\cdashline{2-6}
& 関する & kansuru & betreffen & 1 & 10,2 \\
\rowcolor{gray!10}
Adn
& & & & 1 & 10,6 \\
& 然したる & sashitaru & nicht sonderlich & 1 & 10,9 \\
\rowcolor{gray!10}
no + Pron.
& & & & 7 & 7,1 \\
& 門 & monkado & Tor & 3 & 12,3 \\
\cdashline{2-6}
& 根源 & kongen & Ursprung & 1 & 10,4 \\
\cdashline{2-6}
& 身 & mi & Körper & 1 & 10,4 \\
\rowcolor{gray!10}
Kompositum
& & & & 1 & 13,4 \\
& 仏郎察 & futsu rō satsu & Frankreich & 1 & 13,4 \\
\end{xltabular}
\endgroup
\end{document}
xcolor
andcolortbl
packages separately. Just run\usepackage[table]{xcolor}
and do not loadcolortbl
via a separate instruction.\caption
but it works if you make it the second line with an empty first line.\begin{xltabular}{\textwidth}{lcll} \\\noalign{\vspace{-20pt}} \caption{Übersicht des historischen Korpus (CHJ) von Chunagon\label{ta:choverview}}\\