2

如何使用 Latex 创建表,如下所示。表格必须适合 2 列页面格式中的 1 列,但表格标题太长,第一列中的内容也太长。所以,我想用粗体格式将第一列的列标题和内容分成多行。

桌子

不太清楚为什么 \makecell 不合作粗体文本并设计一个实心边框,但这是我的乳胶代码:


\begin{table}[h]    
\begin{center}
\begin{tabularx}{\linewidth}{|L|L|L|L|L|}
\toprule

\makecell[lt]{Type} 
&\makecell[lt]{Financial \\ benefit \\ of the \\users}
& \makecell[lt]{Financial\\ loss of the \\ users} 
&\makecell[lt]{Interruption \\ of user’ \\ daily activity}
&\makecell[lt]{Monetary \\ reward \\ for works}\\

\midrule
\makecell[lt]{Category 1: \\ Work in \\ the retail \\ sector}
 & \ding{51}
 & \ding{51}
 & 
 & \ding{51}\\
 
\midrule
\makecell[lt]{Category 2: \\ Work in \\ the industry \\ sector}
 & \ding{51}
 & \ding{51}
 & \ding{51}
 & \ding{51}\\
 
\midrule
\makecell[lt]{Category 3: \\ Work in \\ the corporate \\ sector}
 & \ding{51}
 & \ding{51}
 & \ding{51}
 & \ding{51}\\
\bottomrule
\end{tabularx}
\end{center}
\end{table}

4

1 回答 1

1

为您提供了一种新的package array表格单元格类型

p={fixed width}

通过这种单元格类型,您可以定义两种新的单元格类型来满足您的对齐要求:

\newcolumntype{F}[1]{%
    >{\raggedright\arraybackslash\hspace{0pt}}p{#1}}%
\newcolumntype{T}[1]{%
    >{\centering\arraybackslash\hspace{0pt}}p{#1}}%

输出

完整代码:

\documentclass{article}

\usepackage{array}

\newcolumntype{F}[1]{%
    >{\raggedright\arraybackslash\hspace{0pt}}p{#1}}%
\newcolumntype{T}[1]{%
    >{\centering\arraybackslash\hspace{0pt}}p{#1}}%

\begin{document}

\begin{table}
\begin{tabular}{|F{0.2\textwidth}|T{0.2\textwidth}|T{0.2\textwidth}|T{0.2\textwidth}|T{0.2\textwidth}|}
\hline
\textbf{\hfil Type}&
\textbf{Financial benefit of the users}&
\textbf{Financial loss of the users }&
\textbf{Interruption of user daily activity}&
\textbf{Monetary reward for works}\\ 
\hline
\textbf{Category 1: Work in  the retail  sector } &\textbf{v}&&v&v \\
\hline
\textbf{Category 2: Work in  the industry  sector} &v&v&v&v \\  
\hline
\textbf{Category 3: Work in  the corporate  sector}  &&v&v&v \\
\hline
\end{tabular}
\end{table}

\end{document}
于 2020-11-09T07:16:42.660 回答