不使用 colortbl 对表格单元格进行着色

不使用 colortbl 对表格单元格进行着色

我有一张表格,我想给其中的某些单元格加阴影。我知道使用 colortbl 和 xcolor 可以轻松实现这一点,但 colortbl 包与我正在使用的另一个包 (OTtablx) 冲突。还有其他方法可以为表格单元格加阴影吗?或者,有没有办法只针对这张表关闭冲突的包,然后再将其重新打开?

OTtablx(“大量使用 PSTricks,从而阻止直接使用 pdfLATEX 生成 PDF”,如果相关的话)可以轻松地以我所在学科特有的特殊格式制作表格。我在整个文档中都使用这些格式,现在无法更改它们。我不在乎无法为这些特殊表格添加阴影,我只想为一个常规表格添加阴影。我目前的解决方法是在 word 中制作它,截取屏幕截图,在 photoshop 中转换为 .eps,然后将其放入 \includegraphics 中。丑陋,丑陋,丑陋。

以下是 MWE:

\documentclass[12pt,oneside]{book}
\usepackage[top=1.375in,left=1in,right=1in,bottom=1in,headheight=.25in,headsep=.2in]{geometry}

\usepackage{threeparttablex}
\usepackage{booktabs} % for much better looking tables
\usepackage{multirow, multicol}

%\usepackage{tipa} %included in OTtablx, don't need to load separately unless you need to use options
\usepackage [medium] {OTtablx} %must run with tex and dvi not pdftex

\newcommand{\0}{$\emptyset$} %null


\begin{document}
Here is a plain, unshaded table.
\begin{table}[h]
{\begin{threeparttable}\caption{Agreement paradigms}\label{table:comboagree}
\centering
\fontsize{10.5}{12}\selectfont
  \begin{tabular}{ r l l@{}r lr@{\extracolsep{1em}}l@{}r l@{}r@{\extracolsep{1em}}l@{}r l@{}r }
\toprule
&&\multicolumn{4}{c}{\textbf{Indicative}}&\multicolumn{4}{c}{\textbf{Optative}}&\multicolumn{4}{c}{\textbf{Negative}}\\
\midrule
\multicolumn{14}{l}{{A. OBJECT AGREEMENT}}\\[0.5ex]
\textbf{Obj} & \textbf{Subj} &\multicolumn{2}{l}{\textbf{s}}&\multicolumn{2}{l}{\textbf{pl}}&\multicolumn{2}{l}{\textbf{s}}&\multicolumn{2}{l}{\textbf{pl}}&\multicolumn{2}{l}{\textbf{s}}&\multicolumn{2}{l}{\textbf{pl}}\\
\cmidrule{3-6}\cmidrule{7-10}\cmidrule{11-14}
1s\phantom{} & &    na-&&kana-&\phantom{-i}&    na-&-i&kana-&-i&    na-&-ara&kana-&-ap\\
1pl & &         kin-&&&&                    kin-&-i&&&      kin-&-ap&&\\
2s\phantom{} & &    i-&-ap&&&                   i-&-ap&&&           \0-&-ap&&\\
2pl & &         kii(k)-&-ap&&&              kii(k)-&-ap&&&      kii(k)-&-ap&&\\
[0.5ex]\midrule
\multicolumn{14}{l}{{B. SUBJECT AGREEMENT}}\\[0.5ex]
\textbf{Subj} & \textbf{Obj} &\multicolumn{2}{l}{\textbf{s}}&\multicolumn{2}{l}{\textbf{pl}}&\multicolumn{2}{l}{\textbf{s}}&\multicolumn{2}{l}{\textbf{pl}}&\multicolumn{2}{l}{\textbf{s}}&\multicolumn{2}{l}{\textbf{pl}}\\
\cmidrule{3-6}\cmidrule{7-10}\cmidrule{11-14}
    &\textbf{2nd}&  &&&&&&&&&&\\
1\phantom{} & & nu-&\phantom{-i}&n/a&&      nu-&-i&n/a&&        kin-&-ara&n/a&\\[0.5ex]
    &\multicolumn{5}{l}{\textbf{3rd/intransitive}}&     &&&&            &&&\\
1s\phantom{} & &    ni-&&&&                 kan-&-i&&&      na-&-ara&&\\
2s\phantom{} & &    i-&&&&                  \0-&-i&&&           \0-&-ara&&\\
3s\phantom{} & &    u-&&&&                  kam-&-i&&&      \0-&-ara&\0-&-ap\\
1pl & &         nu-&&&&                 nu-&-i&&&           kin-&-ara&&\\
2pl & &         ku-&&&&                 kii(k)-&-i&&&       \0-&-ap&&\\
3pl & &         kun-&&kin-&\phantom{-i}&        kun-&-i&kin-&-i&    \0-&-ap&kin-&-ap\\
\bottomrule
\end{tabular}
 \begin{tablenotes} 
  \small
  \item[a] Unless marked \textit{n/a}, when no entry is given in the plural column, the agreement affixes listed in the singular colum apply for both singular and plural.
  \end{tablenotes}
\end{threeparttable}}
\end{table}
\normalsize


%And just for reference, here is the code for a table produced by OTtablx.
%
%\begin{OTtableau}{5}
%   \OTsolids{3,4,5}\OTdashes{1,2}
%   \OTtoprow    [/avansa/] { {\sc Max-C}, {\sc *CC-Coda}, {\sc Dep}, {*V\#},{\sc Max-V}}
%   \OTcandrow {avan} {*!,,,,*}
%   \OTcandrow {avans} {,*!,,,*}
%   \OTcandrow [\OThand] {avansa} {,,,*,}
%\end{OTtableau}

\end{document}

这是我希望表格看起来的样子(我也不知道如何做注释,但阴影是我的首要任务): 所需的阴影

编辑后添加:以下是正常情况下的图片,以及当我在实际文档中加载 colortbl(或数组)时 OTtablx 发生的情况。这不会发生在 MWE 中,我不知道为什么。

正常 OTtablx

OTtablx 中的第一个单元格超出右边缘

答案1

正如 Bernard 在他的回答中所说,使用 XeLaTeX 进行编译可以满足您的需求。它还允许您使用 TikZ 向表中添加注释:

% !TEX TS-program = xelatex
\documentclass[12pt,oneside]{book}
\usepackage[top=1.375in,left=1in,right=1in,bottom=1in,headheight=.25in,headsep=.2in]{geometry}
\usepackage[table]{xcolor}
\usepackage{threeparttablex}
\usepackage{booktabs} % for much better looking tables
\usepackage{multirow, multicol}

%\usepackage{tipa} %included in OTtablx, don't need to load separately unless you need to use options
\usepackage [medium] {OTtablx} %must run with tex and dvi not pdftex
\newcommand{\cgr}{\cellcolor[gray]{.90}}
\newcommand{\0}{$\emptyset$} %null
\usepackage{tikz}
\usetikzlibrary{fit,shapes.geometric,decorations.pathreplacing,calc}
\newcommand\tikzmk[1]{\tikz[remember picture,overlay]\node (#1) {};}

\begin{document}
Here is a plain, unshaded table.
\begin{table}[h]
{\begin{threeparttable}\caption{Agreement paradigms}\label{table:comboagree}
\centering
\fontsize{10.5}{12}\selectfont
  \begin{tabular}{ r l l@{}r lr@{\extracolsep{1em}}l@{}r l@{}r@{\extracolsep{1em}}l@{}r l@{}r }
\toprule
&&\multicolumn{4}{c}{\textbf{Indicative}}&\multicolumn{4}{c}{\textbf{Optative}}&\multicolumn{4}{c}{\textbf{Negative}}\\
\midrule
\multicolumn{14}{l}{{A. OBJECT AGREEMENT}}\\[0.5ex]
\textbf{Obj} & \textbf{Subj} &\multicolumn{2}{l}{\textbf{s}}&\multicolumn{2}{l}{\textbf{pl}}&\multicolumn{2}{l}{\textbf{s}}&\multicolumn{2}{l}{\textbf{pl}}&\multicolumn{2}{l}{\textbf{s}}&\multicolumn{2}{l}{\textbf{pl}}\\
\cmidrule{3-6}\cmidrule{7-10}\cmidrule{11-14}
1s\phantom{} & &    na-&&kana-&\phantom{-i}&    na-&-i&kana-&-i&    na-&-ara&kana-&-ap\tikzmk{G}\\
1pl & &         kin-&&&&                    kin-&-i&&&      kin-&-ap&&\tikzmk{H}\\
2s\phantom{} &\tikzmk{A} & \cgr i- &\multicolumn{3}{>{\cgr}l}{-ap} & \cgr i- & \multicolumn{3}{>{\columncolor{gray!20}[12pt][6pt]}l}{-ap} & \cgr \0- & \multicolumn{3}{>{\columncolor{gray!20}[12pt][3pt]}l}{-ap}\tikzmk{I}\\
2pl &\hspace*{1cm}\tikzmk{B} & \cgr kii(k)-&\multicolumn{3}{>{\cgr}l}{-ap} & \cgr kii(k)-& \multicolumn{3}{>{\columncolor{gray!20}[12pt][6pt]}l}{-ap}& \cgr kii(k)- & \multicolumn{3}{>{\columncolor{gray!20}[12pt][3pt]}l}{-ap}\tikzmk{J}\\
[0.5ex]\midrule
\multicolumn{14}{l}{{B. SUBJECT AGREEMENT}}\\[0.5ex]
\textbf{Subj} & \textbf{Obj} &\multicolumn{2}{l}{\textbf{s}}&\multicolumn{2}{l}{\textbf{pl}}&\multicolumn{2}{l}{\textbf{s}}&\multicolumn{2}{l}{\textbf{pl}}&\multicolumn{2}{l}{\textbf{s}}&\multicolumn{2}{l}{\textbf{pl}}\\
\cmidrule{3-6}\cmidrule{7-10}\cmidrule{11-14}
    &\textbf{2nd}&  &&&&&&&&&&\\
1\phantom{} &\tikzmk{C} &\cgr nu-&\phantom{-i}&n/a&&      nu-&-i&n/a&&        kin-&-ara&n/a&\tikzmk{E}\\[0.5ex]
    &\multicolumn{5}{l}{\textbf{3rd/intransitive}}&     &&&&            &&&\\
1s\phantom{} & &\multicolumn{4}{>{\cgr}l}{ni-}&                 kan-&-i&&&      na-&-ara&&\\
2s\phantom{} & &\multicolumn{4}{>{\cgr}l}{i-}&                  \0-&-i&&&           \0-&-ara&&\\
3s\phantom{} & &\multicolumn{4}{>{\cgr}l}{u-}&                  kam-&-i&&&      \0-&-ara&\0-&-ap\\
1pl & &\multicolumn{4}{>{\cgr}l}{nu-}&                 nu-&-i&&&           kin-&-ara&&\\
2pl & &\multicolumn{4}{>{\cgr}l}{ku-}&                 \cgr kii(k)-&-i&&&       \0-&-ap&&\\
3pl &\tikzmk{D} &\cgr         kun-&& kin-&\phantom{-i}&       \cgr kun-&-i& kin-&-i&    \0-&-ap&kin-&-ap\tikzmk{F}\\
\bottomrule 
\end{tabular}
 \begin{tablenotes} 
  \small
  \item[a] Unless marked \textit{n/a}, when no entry is given in the plural column, the agreement affixes listed in the singular colum apply for both singular and plural.
  \end{tablenotes}
\end{threeparttable}}
\begin{tikzpicture}[overlay,remember picture]
\node[draw,fit=(A) (B),font={\scriptsize\scshape},inner sep=0pt,align=center] {inverse};
\draw[decorate,decoration={brace,amplitude=5pt},thick,draw=blue] ($(D)+(20pt,-5pt)$) -- node[pos=.4,rotate=90,yshift=10pt,font=\scriptsize] {non-cohering} ($(C)+(20pt,10pt)$);\draw[decorate,decoration={brace,amplitude=5pt},thick,draw=blue] ($(E)+(5pt,10pt)$) -- node[midway,rotate=90,yshift=-10pt,font=\scriptsize] {cohering} ($(F)+(5pt,0pt)$);
\draw[decorate,decoration={brace,amplitude=2pt},thick,draw=blue,yshift=2pt] ($(G)+(4pt,5pt)$) -- node[midway,xshift=20pt,font=\scriptsize] {cohering} ($(H)+(4pt,-5pt)$);\draw[decorate,decoration={brace,amplitude=2pt},thick,draw=blue,yshift=2pt] ($(I)+(-2pt,5pt)$) -- node[midway,xshift=20pt,font=\scriptsize,align=center] {non-\\cohering} ($(J)+(-2pt,-5pt)$);
\end{tikzpicture}
\end{table}
\normalsize


And just for reference, here is the code for a table produced by OTtablx.

\begin{OTtableau}{5}
   \OTsolids{3,4,5}\OTdashes{1,2}
   \OTtoprow    [/avansa/] { {\sc Max-C}, {\sc *CC-Coda}, {\sc Dep}, {*V\#},{\sc Max-V}}
   \OTcandrow {avan} {*!,,,,*}
   \OTcandrow {avans} {,*!,,,*}
   \OTcandrow [\OThand] {avansa} {,,,*,}
\end{OTtableau}

\end{document}

代码输出

答案2

您可以使用文档类选项进行编译xelatex并调用选项,这将调用。它可以编译得很好。tablecolortbl

pdflatex如果你加载auto-pst-pdf (要加载的 pstricks并且如果您将-shell-escape开关添加到编译器中)几乎因为OTtableau没有显示,因为它需要一种我所不支持的真类型字体(所以与 pstricks/colortbl 无关)。

\documentclass[12pt,oneside, table, svgnames]{book}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[top=1.375in,left=1in,right=1in,bottom=1in,headheight=.25in,headsep=.2in]{geometry}

\usepackage{threeparttablex}
\usepackage{booktabs} % for much better looking tables
\usepackage{multirow, multicol}

%\usepackage{tipa} %included in OTtablx, don't need to load separately unless you need to use options
\usepackage [medium] {OTtablx} %must run with tex and dvi not pdftex
\usepackage{xcolor}
\newcommand\greycell{\cellcolor{Gainsboro!70}}
\newcommand{\0}{$\emptyset$} %null
%\usepackage{auto-pst-pdf}

\begin{document}
Here is a plain, unshaded table.
\begin{table}[h]
{\begin{threeparttable}\caption{Agreement paradigms}\label{table:comboagree}
\centering
\fontsize{10.5}{12}\selectfont
  \begin{tabular}{ r l l@{}r lr@{\extracolsep{1em}}l@{}r l@{}r@{\extracolsep{1em}}l@{}r l@{}r }
\toprule
&&\multicolumn{4}{c}{\textbf{Indicative}}&\multicolumn{4}{c}{\textbf{Optative}}&\multicolumn{4}{c}{\textbf{Negative}}\\
\midrule
\multicolumn{14}{l}{{A. OBJECT AGREEMENT}}\\[0.5ex]
\textbf{Obj} & \textbf{Subj}
&\multicolumn{2}{l}{\textbf{s}}&\multicolumn{2}{l}{\textbf{pl}}&\multicolumn{2}{l}{\textbf{s}}&\multicolumn{2}{l}{\textbf{pl}}&\multicolumn{2}{l}{\textbf{s}}&\multicolumn{2}{l}{\textbf{pl}}\\
\cmidrule{3-6}\cmidrule{7-10}\cmidrule{11-14}
1s\phantom{} & & na-&&kana-&\phantom{-i}& na-&-i&kana-&-i& na-&-ara&kana-&-ap\\
1pl & & kin-&&&& kin-&-i&&& kin-&-ap&&\\
2s\phantom{} & & \greycell i- &\multicolumn{3}{>{\greycell}l}{-ap} & \greycell i- & \multicolumn{3}{>{\columncolor{Gainsboro!70}[12pt][6pt]}l}{-ap} & \greycell \0- & \multicolumn{3}{>{\columncolor{Gainsboro!70}[12pt][6pt]}l}{-ap}\\
2pl & & \greycell kii(k)-&\multicolumn{3}{>{\greycell}l}{-ap} & \greycell kii(k)-& \multicolumn{3}{>{\columncolor{Gainsboro!70}[12pt][6pt]}l}{-ap}& \greycell kii(k)- & \multicolumn{3}{>{\columncolor{Gainsboro!70}[12pt][6pt]}l}{-ap} \\
[0.5ex]\midrule
\multicolumn{14}{l}{{B. SUBJECT AGREEMENT}}\\[0.5ex]
\textbf{Subj} & \textbf{Obj}
&\multicolumn{2}{l}{\textbf{s}}&\multicolumn{2}{l}{\textbf{pl}}&\multicolumn{2}{l}{\textbf{s}}&\multicolumn{2}{l}{\textbf{pl}}&\multicolumn{2}{l}{\textbf{s}}&\multicolumn{2}{l}{\textbf{pl}}\\
\cmidrule{3-6}\cmidrule{7-10}\cmidrule{11-14}
    &\textbf{2nd}& &&&&&&&&&&\\
1\phantom{} & & \greycell nu- &\greycell \phantom{-i}& n/a&& nu-&-i&n/a&& kin-&-ara&n/a&\\[0.5ex]
    &\multicolumn{5}{l}{\textbf{3rd/intransitive}}& &&&& &&&\\
1s\phantom{} & & \multicolumn{4}{>{\greycell}l}{ni-} & kan-&-i&&& na-&-ara&&\\
2s\phantom{} & & \multicolumn{4}{>{\greycell}l}{i-} & \0-&-i&&& \0-&-ara&&\\
3s\phantom{} & & \multicolumn{4}{>{\greycell}l}{u-} & kam-&-i&&& \0-&-ara&\0-&-ap\\
1pl & & \multicolumn{4}{>{\greycell}l}{nu-} & nu-&-i & & & kin-&-ara & &\\
2pl & & \multicolumn{4}{>{\greycell}l}{ku-}& \greycell kii(k)- & \multicolumn{3}{>{\columncolor{Gainsboro!70}[12pt][6pt]}l}{-i}& \0-&-ap&&\\
3pl & & \multicolumn{2}{>{\greycell}l}{kun-} &kin-&\phantom{-i}& \greycell kun- & \greycell -i&kin-&-i& \0-&-ap&kin-&-ap\\
\bottomrule
\end{tabular}
 \begin{tablenotes}
  \small
  \item[a] Unless marked \textit{n/a}, when no entry is given in the plural column, the agreement affixes listed in the singular colum apply for
      both singular and plural.
  \end{tablenotes}
\end{threeparttable}}
\end{table}
\normalsize

And just for reference, here is the code for a table produced by OTtablx.

\begin{OTtableau}{5}
 \OTsolids{3,4,5}\OTdashes{1,2}
 \OTtoprow [/avansa/] { {\sc Max-C}, {\sc *CC-Coda}, {\sc Dep}, {*V\#},{\sc Max-V}}
 \OTcandrow {avan} {*!,,,,*}
 \OTcandrow {avans} {,*!,,,*}
 \OTcandrow [\OThand] {avansa} {,,,*,}
\end{OTtableau}

\end{document}

在此处输入图片描述

相关内容