创建一个适合线宽的表格,并且在颜色填充的单元格之间没有细的白色垂直线

创建一个适合线宽的表格,并且在颜色填充的单元格之间没有细的白色垂直线

有人能帮我制作这个线程中编码的表格吗https://tex.stackexchange.com/a/301036/229635适合线宽吗?

作为 MWE,我从作为链接附加的线程中复制了代码。

非常感谢,Cheers Benson_G

在此处输入图片描述

\documentclass[a4paper,12pt, enabledeprecatedfontcommands, toc = sectionentrywithdots]{scrartcl} %Art des Dokuments, Schriftgröße etc. , idxtotoc, bibtotoc,
\usepackage[onehalfspacing]{setspace} %Zeilenabstand
\usepackage[hmargin={3cm,2cm},vmargin=2cm, includehead]{geometry}%Maße für die wissenschaftliche Arbeit
\usepackage[scaled=0.9]{helvet}
\renewcommand{\familydefault}{\sfdefault}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{array}
\usepackage{hhline}
\usepackage{color}
\usepackage{colortbl}
 \definecolor{gr}{RGB}{240,240,240}
\usepackage{tabularx}
\usepackage{babel}

\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}


\begin{document}

\noindent
\begin{tabularx}{\textwidth}{XXXX}
    \hhline{----}
    \multicolumn{1}{>{\centering\columncolor{gr}}m{.1\textwidth}} {Here's a box\\ Score} 
            & \multicolumn{1}{>{\centering\columncolor{gr}}m{.3\textwidth}}{Here's a box\\ Score}
                        & \multicolumn{1}{>{\centering\columncolor{gr}[\dimexpr\tabcolsep + 0pt\relax]}m{.3\textwidth}}{Another Box\\ with two Rows} %
                                    & \multicolumn{1}{>{\centering\columncolor{gr}[\tabcolsep]}m{.3\textwidth}|}{Student's\\ Proficiency Level}
    \tabularnewline%
    \hline
    Science     & 28    & 26 or above     & Proficient\tabularnewline
    \hline
  \end{tabularx}

\end{document} 

答案1

这是表格的第一个粗略版本,现在适合文本宽度。

在此处输入图片描述

\documentclass[a4paper,12pt, toc = sectionentrywithdots]{scrartcl}
\usepackage[onehalfspacing]{setspace}
\usepackage[hmargin={3cm,2cm},vmargin=2cm, includehead]{geometry}
\usepackage[scaled=0.9]{helvet}
\renewcommand{\familydefault}{\sfdefault}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{array}
\usepackage{hhline}
%\usepackage{color}
%\usepackage{colortbl}
\usepackage[table]{xcolor} % replaces above two lines
 \definecolor{gr}{RGB}{240,240,240}
\usepackage{tabularx}
\usepackage{babel}

\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}

\renewcommand{\tabularxcolumn}[1]{m{#1}}
\newcolumntype{Y}{>{\centering\arraybackslash}X}

\begin{document}

\noindent
\begin{tabularx}{\textwidth}{>{\centering\arraybackslash}m{.1\textwidth}YYY}
        \hhline{----}
        \multicolumn{1}{>{\centering\columncolor{gr}}m{.1\textwidth}} {Here's a box\\ Score} 
                & \multicolumn{1}{>{\centering\columncolor{gr}}X}{Here's a box\\ Score}
                            & \multicolumn{1}{>{\centering\columncolor{gr}[\dimexpr\tabcolsep + 0pt\relax]}X}{Another Box\\ with two Rows} %
                                        & \multicolumn{1}{>{\centering\columncolor{gr}[\tabcolsep]}X|}{Student's\\ Proficiency Level}
        \tabularnewline%
        \hline
        Science     & 28    & 26 or above     & Proficient\tabularnewline
        \hline
\end{tabularx}
    
\end{document} 

在...的帮助下cellspace

在此处输入图片描述

\documentclass[a4paper,12pt, toc = sectionentrywithdots]{scrartcl}
\usepackage[onehalfspacing]{setspace}
\usepackage[hmargin={3cm,2cm},vmargin=2cm, includehead]{geometry}
\usepackage[scaled=0.9]{helvet}
\renewcommand{\familydefault}{\sfdefault}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{array}
\usepackage{hhline}
%\usepackage{color}
%\usepackage{colortbl}
\usepackage[table]{xcolor} % replaces above two lines
 \definecolor{gr}{RGB}{240,240,240}
\usepackage{tabularx}
\usepackage{babel}

\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}

\renewcommand{\tabularxcolumn}[1]{m{#1}}
\newcolumntype{Y}{>{\centering\arraybackslash}X}

\usepackage[column=0]{cellspace}
\setlength{\cellspacetoplimit}{20pt}
\setlength{\cellspacebottomlimit}{\cellspacetoplimit}
\addparagraphcolumntypes{X}
\begin{document}

\noindent
\begin{tabularx}{\textwidth}{>{\centering\arraybackslash}m{.1\textwidth}YYY}
        \hhline{----}
        \multicolumn{1}{>{\centering\columncolor{gr}}0{m{.1\textwidth}}} {Here's a box\\ Score} 
                & \multicolumn{1}{>{\centering\columncolor{gr}}0{X}}{Here's a box\\ Score}
                            & \multicolumn{1}{>{\centering\columncolor{gr}[\dimexpr\tabcolsep + 0pt\relax]}0{X}}{Another Box\\ with two Rows} %
                                        & \multicolumn{1}{>{\centering\columncolor{gr}[\tabcolsep]}0{X}|}{Student's\\ Proficiency Level}
        \tabularnewline%
        \hline
        Science     & 28    & 26 or above     & Proficient\tabularnewline
        \hline
\end{tabularx}
    
\end{document} 

答案2

大家好,@leandriis,

我可以自己解决我的问题。

最终的代码如下所示...以防您感兴趣:它包含一种方法:

  1. 使用上面这个线程中的@leandriis 代码来解决颜色填充单元格之间出现白色细垂直线的问题

  2. 仅使用以下方法更改第一行的行高

\usepackage{stackengine} % Package to change row height
\newcommand\xrowht[2][0]{\addstackgap[.5\dimexpr#2\relax]{\vphantom{#1}}} 

在序言中以及\xrowht{10pt}文本的多列花括号内。(如何指定 LaTeX 表格中的行高?

  1. 仅在两个特定单元格之间添加垂直空间,并\addlinespace[0.2cm]在新制表行命令后立即添加(在表格中插入一个小的垂直空间

在此处输入图片描述

\documentclass[a4paper,12pt, enabledeprecatedfontcommands, toc = sectionentrywithdots]{scrartcl} %Art des Dokuments, Schriftgröße etc. , idxtotoc, bibtotoc,
\usepackage[onehalfspacing]{setspace} %Zeilenabstand
\usepackage[hmargin={3cm,2cm},vmargin=2cm, includehead]{geometry}%Maße für die wissenschaftliche Arbeit
\usepackage[parfill]{parskip} %Bessere Seitenumbrüche
\usepackage[T1]{fontenc} %Silbentrennung
\usepackage[german]{babel} %Sprachanpassungen
\usepackage{ragged2e} %für Blocksatzschalter \justifying
% \usepackage[utf8]{inputenc} %Direkte Angabe von Umlauten möglich 
\usepackage{csquotes}
\usepackage{graphicx} %Einfügen von Bildern
% \usepackage{tabularx} %Tabellen
% \usepackage{booktabs} %Weitere Möglichkeiten für Tabellen
\usepackage{here} %Lage von Tabellen und Bildern 
\usepackage{physics}
\usepackage{amsmath}
\usepackage{mathrsfs}
\usepackage{textgreek}
\usepackage{textcomp}
\usepackage{amssymb}
% \usepackage[labelformat=simple]{subcaption}
\usepackage{float}
\usepackage{pdfpages}
\usepackage{lmodern} 
\usepackage{enumitem}
\usepackage{parskip}
\usepackage[hyphens]{url} % be sure to specify the option 'hyphens'
% \usepackage[pdftex,bookmarksnumbered,hidelinks,breaklinks]{hyperref}
% \usepackage[superscript]{cite}

% ======SCHRIFTART=================================

% Schriftart Helvetica
\usepackage[scaled]{helvet}
\renewcommand\familydefault{\sfdefault}

% ===================================================

\usepackage[per-mode = reciprocal, output-decimal-marker={,}, exponent-product = {\cdot}]{siunitx} %Si-Einheiten


\usepackage[headsepline,automark, draft = false]{scrlayer-scrpage} %Für Kopf und Fußzeile und Seitenzahlen
\clearpairofpagestyles
\ihead{\headmark}
\rohead{\pagemark}
% \cfoot{\pagemark}
\addtokomafont{pageheadfoot}{\upshape}
\KOMAoptions{onpsinit={\linespread{1}\selectfont}}

%=======TABELLEN=====================================
\usepackage{booktabs, tabularx}  

\newcolumntype{Y}{>{\centering\arraybackslash}X}

\usepackage{stackengine} % Für Zeilenabstand
\newcommand\xrowht[2][0]{\addstackgap[.5\dimexpr#2\relax]{\vphantom{#1}}}

\renewcommand\tabularxcolumn[1]{m{#1}}

\usepackage[version=4]{mhchem}  % newest version
\usepackage{siunitx}% instead of units, which is deprecate
\sisetup{detect-weight,detect-mode}%Si-Einheiten
\usepackage[labelsep = period, skip=1ex, format=plain, font=small, labelfont=bf, justification = justified]{caption}     % new
%\usepackage[labelformat=simple]{subcaption}
\usepackage{colortbl}
\definecolor{ExpBlau}{rgb}{0.11,0.19,0.46}
\definecolor{gr}{rgb}{0.90,0.90,0.90}

%=====================================================
%=====================================================

\begin{document}

\renewcommand{\tablename}{Tabelle}
\renewcommand{\figurename}{Abbildung}
\captionsetup[table]{justification = raggedright, font=normal, singlelinecheck=false}

\begin{table}[htb!]
  \centering
  \footnotesize
  \setlength\belowcaptionskip{5 pt}
  \caption{\textbf{Molekulare Eigenschaften der P(EO-\textit{co}-EPB)-Copolymere$^{\textcolor{ExpBlau}a}$}}
\noindent
\begin{tabularx}{\textwidth}{>{\centering\arraybackslash}m{.04\textwidth}>{\centering\arraybackslash}m{.185\textwidth}YYYY}
    
        \multicolumn{1}{>{\centering\columncolor{gr}}m{.04\textwidth}} {\xrowht{10pt}Nr.} 
                    & \multicolumn{1}{>{\centering\columncolor{gr}[\dimexpr\tabcolsep + 0.3pt\relax]}m{.185\textwidth}} {\xrowht{10pt}Copolymer} 
                            & \multicolumn{1}{>{\centering\columncolor{gr}[\dimexpr\tabcolsep + 0.3pt\relax]}X}{\xrowht{10pt}$\textit{M}_\text{n, NMR}$ (\si{\gram\per\mole})}
                                        & \multicolumn{1}{>{\centering\columncolor{gr}[\dimexpr\tabcolsep + 0.3pt\relax]}X}{\xrowht{10pt} mol\% EPB$^{\textcolor{ExpBlau}c}$} %
                                                    & \multicolumn{1}{>{\centering\columncolor{gr}[\dimexpr\tabcolsep + 0.3pt\relax]}X}{\xrowht{10pt}$\textit{M}_\text{n, GPC}$ (\si{\gram\per\mole})} %
                                                                & \multicolumn{1}{>{\centering\columncolor{gr}[\tabcolsep]}X}{\xrowht{10pt} \textit{Đ}}
        \tabularnewline\addlinespace[0.2cm]  
                                                                                                                                                          %  SASSK
                            1                             &    ThatsALongWord    &  xxxx  &  x,x  &  xxxx  &  x,xx \tabularnewline      %   113
                            2                             &    ThatsALongWord    &  xxxx  &  x,x  &  xxxx  &  x,xx \tabularnewline      %   114
           \hspace{ 0.5mm}  3$^{\textcolor{ExpBlau}b}$    &    ThatsALongWord    &  xxxx  &  x,x  &  xxxx  &  x,xx \tabularnewline      %   101
                            4                             &    ThatsALongWord    &  xxxx  &  x,x  &  xxxx  &  x,xx \tabularnewline      %   111
                            5                             &    ThatsALongWord    &  xxxx  &  x,x  &  xxxx  &  x,xx \tabularnewline      %   105
                            6                             &    ThatsALongWord    &  xxxx  &  x,x  &  xxxx  &  x,xx \tabularnewline      %   112
\end{tabularx}
    \vspace{0.6 \baselineskip} \\
    \justifying
    $^{\textcolor{ExpBlau}a}$ Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello
  \label{tab:Copo}
\end{table}

\end{document}

相关内容