表の列間の記号

表の列間の記号

表形式の 2 つの列の間にいくつかの記号を追加する必要がありました。下の図は必要な出力です。これを実現する方法がわかりません。

出力画像

グーグルで調べたらこれOP が同様のことを望んでいた質問です。ただし、すべての行ではなく一部の行を自動化したかったので、そこでの解決策は私の用途には狭すぎました。これを行う他の方法はありますか?

答え1

追加の列がなく、元の間隔が維持されている場合:

\documentclass{article}
\usepackage{array}

\begin{document}

\noindent\begin{tabular}{|ccc|cc|}
\hline
\multicolumn{1}{|c@{\hspace*{\tabcolsep}\makebox[0pt]{-}}}{a}
  & b & c & d & e \\
\hline
a & \multicolumn{1}{c@{\hspace*{\tabcolsep}\makebox[0pt]{-}}}{b}
 & c & d & e \\
\hline
\end{tabular}

\noindent\begin{tabular}{|ccc|cc|}
\hline
a & b & c & d & e \\
\hline
a & b & c & d & e \\
\hline
\end{tabular}

\end{document}

ここに画像の説明を入力してください

アイデアは、幅ゼロのボックスを使用してシンボルを挿入する構文を使用\multicolumnすることです。@{...}

答え2

このソリューションは Steven の提案を取り入れ、列を追加することで間隔を調整します。

\documentclass[a4paper]{article}

\begin{document}

\setlength{\tabcolsep}{2pt}

\begin{table}[h]
\begin{tabular}{|ccccccc|ccccc|}
\hline
 & a & - & b &   & c & & & d & & e &\\
\hline
 & p &   & q & - & r & & & s & & t &\\
\hline
\end{tabular}
\end{table}

\end{document}

ここに画像の説明を入力してください

関連情報