列の幅に合わせたカスタム下線で表のエントリを中央揃えにする

列の幅に合わせたカスタム下線で表のエントリを中央揃えにする

3 列のシンプルな表があり、これをデータの見出しとして使用しています。各表のエントリに下線を引くために、カスタム下線ルール (カスタムの太さ、色、深さ) を定義しました。

私が使用しているマークアップは次のとおりです。

\documentclass[letterpaper,11pt]{article}
\usepackage{kpfonts}
\RequirePackage{fix-cm}
\setlength{\parskip}{\baselineskip}%
\setlength{\parindent}{0pt}%
\usepackage{xcolor}
\definecolor{smokyblack}{rgb}{0.06, 0.05, 0.03}
\definecolor{mygrey}{rgb}{0.1, 0.14, 0.12}
\definecolor{darkjunglegreen}{rgb}{0.0, 0.26, 0.15}
\usepackage[
top    = 0.608cm,
bottom = 1.1cm,
left   = 1.20cm,
right  = 1.10cm]{geometry}
\usepackage{titlesec}
\usepackage{ulem}
\renewcommand{\ULdepth}{5.8pt}
\renewcommand{\ULthickness}{1.35pt} 
\makeatletter 
\newcommand\semiLarge{\@setfontsize\semiLarge{13.22}{17.38}}
\makeatother
\newcommand{\greenuline}[1]{{\color{darkjunglegreen}\uline{{\color{black}#1}}}}
\titleformat{\section}
{\normalfont\Large\bfseries}{\thesection}
{1em}{}[\color{darkjunglegreen}{\titlerule[2pt]}]
\titlespacing\section{0pt}{1pt plus 4pt minus 2pt}{-3pt plus 2pt minus 2pt}

\begin{document}
\sloppy
\begin{tabular*}{\linewidth}{@{}l@{\extracolsep{\fill}}r@{}}
\textbf{\LARGE \textcolor{mygrey}{REAL NAME}}  & \large{[email protected]}\\
\colorbox{mygrey!11}{\textbf{\semiLarge \textcolor{smokyblack}{Employed Professional}}} &  \large{555-555-5555 - New York, NY}
\end{tabular*}

\section*{Section Heading}

\begin{tabular} {@{}p{6cm} p{8cm} p{7cm}}
\large{\textbf{\greenuline{Category}}} & \large{\textbf{\greenuline{Word}}} & \large{\textbf{\greenuline{Much Longer word}}}
\end{tabular}   

\end{document}

次のような出力が生成されます。

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

現時点ではすべて意図したとおりに動作しています。次の図に示すように、各テーブル エントリを列の中央に配置し、下線ルールをテーブル列の幅いっぱいに表示したいと思います。

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

この問題の最も簡単な解決策は何でしょうか?

答え1

\cmidruleパッケージのとを使用してbooktabstabular*テーブルがテキスト幅内に収まるようにします。 のオプション引数を使用して、線の太さを制御できます\cmidrule

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

\documentclass[letterpaper,11pt]{article}
\usepackage{kpfonts}
\RequirePackage{fix-cm}
\setlength{\parskip}{\baselineskip}%
\setlength{\parindent}{0pt}%
\usepackage[table]{xcolor}
\definecolor{smokyblack}{rgb}{0.06, 0.05, 0.03}
\definecolor{mygrey}{rgb}{0.1, 0.14, 0.12}
\definecolor{darkjunglegreen}{rgb}{0.0, 0.26, 0.15}
\usepackage[
top    = 0.608cm,
bottom = 1.1cm,
left   = 1.20cm,
right  = 1.10cm]{geometry}
\usepackage{titlesec}
\usepackage{ulem}
\renewcommand{\ULdepth}{5.8pt}
\renewcommand{\ULthickness}{1.35pt} 
\makeatletter 
\newcommand\semiLarge{\@setfontsize\semiLarge{13.22}{17.38}}
\makeatother
\newcommand{\greenuline}[1]{{\color{darkjunglegreen}\uline{{\color{black}#1}}}}
\titleformat{\section}
{\normalfont\Large\bfseries}{\thesection}
{1em}{}[\color{darkjunglegreen}{\titlerule[2pt]}]
\titlespacing\section{0pt}{1pt plus 4pt minus 2pt}{-3pt plus 2pt minus 2pt}

\usepackage{booktabs}
\usepackage{array}
\usepackage{calc}
\newcolumntype{C}[1]{>{\centering\arraybackslash}p{#1}}
\begin{document}
\sloppy
\begin{tabular*}{\linewidth}{@{}l@{\extracolsep{\fill}}r@{}}
\textbf{\LARGE \textcolor{mygrey}{REAL NAME}}  & \large{[email protected]}\\
\colorbox{mygrey!11}{\textbf{\semiLarge \textcolor{smokyblack}{Employed Professional}}} &  \large{555-555-5555 - New York, NY}
\end{tabular*}

\section*{Section Heading}
\arrayrulecolor{darkjunglegreen}

\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}*{3}{C{0.3\textwidth-2\tabcolsep}}}
\large\textbf{Category} & \large\textbf{Word} & \large\textbf{Much Longer word}\\
\cmidrule[1pt](r){1-1} \cmidrule[1pt](lr){2-2} \cmidrule[1pt](l){3-3}
\end{tabular*}   

\end{document}

答え2

p 列を使用する代わりに、 を使用して幅を設定できます\makebox

BTW< に\largeは引数がありません。これはスイッチなので、中括弧内に記述する必要があります。

\documentclass[letterpaper,11pt]{article}
\usepackage{kpfonts}
\RequirePackage{fix-cm}
\setlength{\parskip}{\baselineskip}%
\setlength{\parindent}{0pt}%
\usepackage{xcolor}
\definecolor{smokyblack}{rgb}{0.06, 0.05, 0.03}
\definecolor{mygrey}{rgb}{0.1, 0.14, 0.12}
\definecolor{darkjunglegreen}{rgb}{0.0, 0.26, 0.15}
\usepackage[
top    = 0.608cm,
bottom = 1.1cm,
left   = 1.20cm,
right  = 1.10cm]{geometry}
\usepackage{titlesec}
\usepackage{ulem}
\renewcommand{\ULdepth}{5.8pt}
\renewcommand{\ULthickness}{1.35pt} 
\makeatletter 
\newcommand\semiLarge{\@setfontsize\semiLarge{13.22}{17.38}}
\makeatother
\newcommand{\greenuline}[1]{{\color{darkjunglegreen}\uline{{\color{black}#1}}}}
\titleformat{\section}
{\normalfont\Large\bfseries}{\thesection}
{1em}{}[\color{darkjunglegreen}{\titlerule[2pt]}]
\titlespacing\section{0pt}{1pt plus 4pt minus 2pt}{-3pt plus 2pt minus 2pt}

\begin{document}
\sloppy
\begin{tabular*}{\linewidth}{@{}l@{\extracolsep{\fill}}r@{}}
\textbf{\LARGE \textcolor{mygrey}{REAL NAME}}  & \large{[email protected]}\\
\colorbox{mygrey!11}{\textbf{\semiLarge \textcolor{smokyblack}{Employed Professional}}} &  \large{555-555-5555 - New York, NY}
\end{tabular*}

\section*{Section Heading}

\begin{tabular*}{\textwidth} {@{\extracolsep{\fill}}lll@{}}
\textbf{\large\greenuline{\makebox[6cm]{Category}}} & \textbf{\large\greenuline{\makebox[6cm]{Word}}} 
  & \textbf{\large\greenuline{\makebox[6cm]{Much Longer word}}}
\end{tabular*}   

\end{document}

関連情報