关于彩色表格

关于彩色表格

我面临的问题是制作一个带有彩色行的表格。目标图片如下:

在此处输入图片描述

我自己关于所需颜色表的 tex 代码如下:

\documentclass[french]{article} 
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{babel}

\usepackage[colorlinks,linkcolor=red]{hyperref}   
\usepackage[dvipsnames]{xcolor}
\usepackage{colortbl}

\newcommand{\zx}[1]{\textcolor{BlueViolet}{\emph{#1}}}


\begin{document}

\renewcommand{\arraystretch}{1.5}
\begin{tabular}{|l@{\textcolor{BlueViolet}{$\bullet$}\hspace{7pt}}p{11cm}|}

        \hline
    \multicolumn{2}{|l|}{ \hspace{3mm}\fcolorbox{black}{BlueViolet} { \strut{\textcolor{white}{\textbf{Key Points}}} } } \\ \hline 

    &  The verb is a word that expresses either an action (\zx{travailler, marcher}) or a state (\zx{être, paraître}).\\

    &  The verb is the core of the sentence, around which the other elements of the sentence (the subject, object, etc.) are arranged.\\

    &  All clauses must contain a verb.\\

    &  The past participle form of the verb (\zx{parlé, vendu,} etc.) can function as an adjective.\\

    &  The infinitive form (\zx{parler, vendre}) can function as a noun.\\ 
    \hline
    \end{tabular}

  \end{document}

以下是我自己编译 tex 代码后的 pdf 快照:

在此处输入图片描述

我的问题是:如何将彩色区域拉伸至表格的左边界。此外,颜色框的边框和表格的顶线之间存在微小的间隙。我不知道如何填补这个间隙,以使表格具有目标图片中显示的完美外观。谢谢。

答案1

习惯可能tcolorbox比环境更好吗?请注意,您可以使用和选项tabular更改“关键点”的确切位置。yshiftxshift

姆韦

\documentclass[12pt]{article}
\usepackage[many]{tcolorbox}
\usepackage[utf8]{inputenc}
\newcommand{\zx}[1]{\textcolor{blue!85!red}{\emph{#1}}}
\newtcolorbox{mybox}[2][]{boxsep=1em,left=-1em,
colback=blue!5!white, colframe=blue!75!black, 
fonttitle=\bfseries\sffamily,
colbacktitle=blue!85!red!60,enhanced,
attach boxed title to top left={yshift=-3mm,xshift=3mm},
title=#2,#1}
\begin{document}

\begin{mybox}{Key Points}
 \def\labelitemi{\textcolor{blue!85!red!60}{$\bullet$}}
\begin{itemize}
\item The verb is a word that expresses either an action
      (\zx{travailler, marcher}) or a state 
      (\zx{être, paraître}).
\item The verb is the core of the sentence, around which
      the other elements of the sentence (the subject, 
      object, etc.) are arranged.
\item All clauses must contain a verb.
\item The past participle form of the verb 
      (\zx{parlé, vendu,} etc.) can function as an adjective.
\item The infinitive form (\zx{parler, vendre}) 
      can function as a noun.
\end{itemize}
\end{mybox}

\end{document}

答案2

在此处输入图片描述

我建议使用enumitem包并在您的表格中制作逐项列表。此外,最好将所有带有彩色框的复杂内容替换为简单的表格单元格,颜色如下\cellcolor{<color}{<cell content>}

\documentclass[french]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{babel}
\usepackage[table,dvipsnames]{xcolor}
\newcommand{\zx}[1]{\textcolor{BlueViolet}{\emph{#1}}}

\usepackage{enumitem}% <-- added
\usepackage[colorlinks,linkcolor=red]{hyperref}% had to be last in preamble!

\begin{document}
\renewcommand{\arraystretch}{1.5}
\begin{tabular}{|ll|}
    \hline
\cellcolor{BlueViolet}{\textcolor{white}{\quad\textbf{Key Points}\quad}}  &   \\
    \hline
\multicolumn{2}{|p{11cm}|}{
    \begin{itemize}[label =\textcolor{BlueViolet}{\textbullet},
                    topsep = 0pt,
                    partopsep = 0pt,
                    leftmargin = *,
                    before = \vspace{-1ex},
                    after = \vspace{-1ex}
                      ]
\item   The verb is a word that expresses either an action (\zx{travailler, marcher}) or a state (\zx{être, paraître}).
\item   The verb is the core of the sentence, around which the other elements of the sentence (the subject, object, etc.) are arranged.
\item   All clauses must contain a verb.
\item   The past participle form of the verb (\zx{parlé, vendu,} etc.) can function as an adjective.
\item   The infinitive form (\zx{parler, vendre}) can function as a noun.
    \end{itemize}
                        }\\
    \hline
\end{tabular}
\end{document}

答案3

这里有一个解决方案,它只在逐项列出项目周围放置一个框架;这样,我相信,“要点”标题矩形实际上会得到更多的视觉突出,而不是更少。

在此处输入图片描述

\documentclass[french]{article}

\usepackage[utf8]{inputenc} 
\usepackage[T1]{fontenc} 
\usepackage{babel}
\usepackage[dvipsnames,table]{xcolor} 
\usepackage[colorlinks,linkcolor=red]{hyperref}
\newcommand{\zx}[1]{\textcolor{BlueViolet}{\emph{#1}}}
\renewcommand{\arraystretch}{1.5}

\begin{document}

\noindent
\begin{tabular}{|l@{\textcolor{BlueViolet}{$\bullet$}\hspace{7pt}}p{11cm}|}
\multicolumn{2}{@{}l}{\fcolorbox{black}{BlueViolet}{%
   \textcolor{white}{\textbf{Key Points}}}  } \\
\hline
&  The verb is a word that expresses either an action (\zx{travailler, marcher}) or a state (\zx{être, paraître}).\\

&  The verb is the core of the sentence, around which the other elements of the sentence (the subject, object, etc.) are arranged.\\

&  All clauses must contain a verb.\\

&  The past participle form of the verb (\zx{parlé, vendu,} etc.) can function as an adjective.\\

&  The infinitive form (\zx{parler, vendre}) can function as a noun.\\ 
\hline
\end{tabular}

\end{document}

相关内容