4

I have a table which I want to shade certain cells of. I know this is simple to do using colortbl and xcolor, but the colortbl package conflicts with another package I am using (OTtablx). Is there any other way to shade table cells? Or, alternatively, is there a way to turn off the conflicting package just for this table and then turn it back on?

OTtablx (which "makes heavy use of PSTricks, which precludes direct use of pdfLATEX to generate PDFs", if that is relevant) makes tables easily in a special format particular to my discipline. I use these throughout this document and can't change them now. I don't care that I can't shade those special tables, I just have one regular table I want to put shading in. My current workaround is to make it in word, take a screenshot, convert to .eps in photoshop, and put it in with \includegraphics. Ugly, ugly, ugly.

Here is a 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}

Here is a picture of what I want the table to look like (I don't know how to do the annotations, either, but shading is my top priority): desired shading

edited to add: Here are pictures of what it normally looks like, and what happens to the OTtablx when I load colortbl (or array) in the actual document. This does not occur in the MWE, and I have no idea why.

normal OTtablx

first cell in OTtablx running off right margin

  • Well if it helps, you could just typeset the table as a separate latex document, compile it to postscript, crop the borders with ps2eps, and include that as a graphic. In this way, you easily get the same fonts etc. that you also use in the main document. – Michael Palmer Aug 3 '17 at 23:29
  • That sounds promising, but I don't have the first idea how to go about doing that. I use TexShop to typeset using LaTeX with script set to Tex + DVI, and I just push the button and it compiles everything and outputs a pdf. I have several separate .tex files I am combining using \include, with only one preamble in the root .tex file. – largercat Aug 3 '17 at 23:42
  • 2
    Instead of showing us the exact table you want, can you show a minimal example that demonstrates how OTtablx conflicts with colortbl and maybe we can solve that problem. – Alan Munn Aug 4 '17 at 0:33
  • @largercat - Alan's advice is good, I would suggest trying that first. As to my own suggestion, you just create a separate latex document for the table. You use the same preamble as for the main document, except that you now load colortbl instead of OTtblx. Add \pagestyle{empty} to the preamble, and put everything from \begin{threeparttable} to \end{threeparttable} inside the document (and nothing else). Then, compile it as you are won't to do. Ctd. ... – Michael Palmer Aug 4 '17 at 0:48
  • 1
    Just to be clear, your example document works with colortbl with no problem. – Alan Munn Aug 4 '17 at 0:50
1

As Bernard says in his answer, compiling with XeLaTeX will do what you want. It also allows you to add annotations to the table using 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}

output of code

1

You can compile with xelatex and call the table option with the document class options, which will call colortbl. It compiles fine.

It also compiles almost fine with pdflatex, if you load auto-pst-pdf (to be loaded after pstricks and if you add the -shell-escape switch to the compiler). Almost because the OTtableau is not displayed, as it requires a true type font for which I have no support (so, unrelated to 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}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.