%20%E3%82%92%E8%A1%A8%E5%BD%A2%E5%BC%8F%E3%81%AE%E5%88%97%E3%81%AB%E3%83%AA%E3%83%80%E3%82%A4%E3%83%AC%E3%82%AF%E3%83%88%E3%81%99%E3%82%8B%E3%81%93%E3%81%A8%E3%81%AF%E5%8F%AF%E8%83%BD%E3%81%A7%E3%81%99%E3%81%8B%3F.png)
この質問は私の前の質問:
>
セルの内容の両側に開き中括弧と閉じ中括弧をパイプして使用することは可能ですか<
? 具体的には、次の列を定義したいのです。
\newcolumntype{P}{>{\leavevmode\kern-\tabcolsep\bfseries\parbox[t]{\hsize}{}X<{}}}
セルの内容を自動的に取り込む列タイプが必要です\parbox
。
短い MNWE を同封します:
\documentclass[table]{article}
\usepackage{lmodern, microtype, xcolor, tabularx, tabulary}
\begin{document}
\begin{tabularx}{0.5\columnwidth}{>{\raggedright\arraybackslash\leavevmode\kern-\tabcolsep\parbox[t]{\hsize}{ }X<{}}XX<{\leavevmode\kern-\tabcolsep\raggedleft\arraybackslash}}
\rowcolor{lightgray}All this testing is not so funny&test&test\\\hline
testing, testing and even more testing &test&test\\
\rowcolor{lightgray}I want to write a noce table in a simple way&test&test\\
\end{tabularx}
\end{document}
答え1
中括弧を と にまたがって記述するの>{}
は<{}
予想以上に難しいようです。明示的な中括弧トークンを使用する方法が思いつきません。TeX の区切り引数を使用する代替ソリューションを次に示します。 を\parbox
直接使用する代わりに、それをラップするヘルパー マクロを定義します\parboxx ... \endparboxx
。このマクロは、新しい列タイプ で使用されますP
。
\documentclass[table]{article}
\usepackage{lmodern, microtype, xcolor, tabularx, tabulary}
\begin{document}
\def\parboxx#1\endparboxx{\parbox[t]{\hsize}{\raggedright#1}}
\newcolumntype{P}{>{\leavevmode\kern-\tabcolsep\bfseries\parboxx}X<{\endparboxx}}
\begin{tabularx}{0.5\columnwidth}{PXX<{\leavevmode\kern-\tabcolsep\raggedleft\arraybackslash}}
\rowcolor{lightgray}All this testing is not so funny&test&test\\\hline
testing, testing and even more testing &test&test\\
\rowcolor{lightgray}I want to write a noce table in a simple way&test&test\\
\end{tabularx}
\end{document}
出力