多行插入表

多行插入表

我有一张这样的桌子: 在此处输入图片描述

但是在“Prerequisiti”和“Tipologia”列的某些单元格中,我需要多行(例如“Node Js | Apache”的情况)。

我希望我的细胞看起来像 在此处输入图片描述 是否可以?

这是我的代码

\begin{center}
\begin{tabular}{ |c|c|c|c|c|c| } 
\hline
Framework & Linguaggio & Licenza & Prerequisiti & Tipologia \\
\hline
Pybossa & Python & Open Source & & Applicazioni Web \\ 
CrowdThruth & PHP & Open source & & Applicazioni Web\\ 
Ionic   & Angularjs & Open source & Node.js | Apache Cordova
& Native | Cross Platform\\
Appcelerator Titanium   & Javascript &  Open Source & Node.js |
Java & Cross platform \\
Xamarin & C\# & Open Source & Visual Studio & Native | Cross Platform \\
Django  & Python    & Open Source&  Python&     Applicazioni web\\
\hline
\end{tabular}
\end{center}

我用 \usepackage{multirow}

但我不知道如何正确使用它。

答案1

s最棒的功能之一(在我看来也是最被低估的:-)功能)tabular是可以嵌套。在这种情况下,如果目的只是让一些单元格中的文本写在更多行中,您只需定义一个命令

\newcommand{\multlinecell}[1]{\begin{tabular}{@{}c@{}}#1\end{tabular}}

取消@{}两侧的间距。然后,您可以将表格键入为

\documentclass{article}

\usepackage{array}

\newcommand{\multlinecell}[1]{\begin{tabular}{@{}c@{}}#1\end{tabular}}

\begin{document}

\begin{tabular}{|*{6}{>{\vphantom{\multlinecell{two\\lines}}}c|}} 
\hline
\bfseries Framework \multlinecell{\strut\\\strut}& \bfseries Linguaggio & \bfseries Licenza & \bfseries Prerequisiti & \bfseries Tipologia \\
\hline
Pybossa & Python & Open Source & & Applicazioni Web \\ 
\hline
CrowdThruth & PHP & Open source & & Applicazioni Web\\ 
\hline
Ionic   & Angularjs & Open source & \multlinecell{Node.js\\Apache Cordova} & \multlinecell{Native\\Cross Platform}\\
\hline
\multlinecell{Appcelerator\\Titanium}   & Javascript &  Open Source & \multlinecell{Node.js\\Java} & Cross platform \\
\hline
Xamarin & C\# & Open Source & Visual Studio & \multlinecell{Native\\Cross Platform} \\
\hline
Django  & Python    & Open Source&  Python &  Applicazioni web \\
\hline
\end{tabular}

\end{document}

在此处输入图片描述

我还使用了\multlinecell强制所有单元格具有相同的高度。

答案2

使用以下makecell软件包:

\documentclass{article}
\usepackage{geometry}% otherwise the text width is to small
\usepackage{makecell}
\renewcommand\theadfont{\bfseries\normalsize}
\setcellgapes{3pt}
%---------------------------------------- for showing page layout
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%

\begin{document}
    \begin{center}
\begin{tabular}{ |*{5}{c|} }
\hline
\thead{Framework} & \thead{Linguaggio} & \thead{Licenza}
        & \thead{Prerequisiti}  & \thead{Tipologia}                \\
\hline
Pybossa & Python & Open Source  & & Applicazioni Web \\
\hline
CrowdThruth & PHP & Open source & & Applicazioni Web\\
\hline
Ionic   & Angularjs & Open source & \makecell{Node.js\\Apache Cordova} & \makecell{Native\\Cross Platform}\\
\hline
\makecell{Appcelerator\\Titanium}   & Javascript &  Open Source & \makecell{Node.js\\ Java} & Cross platform \\
\hline
Xamarin & C\# & Open Source & Visual Studio & \makecell{Native\\Cross Platform} \\
\hline
Django  & Python    & Open Source&  Python &  Applicazioni web \\
\hline
\end{tabular}
    \end{center}
\end{document}

在此处输入图片描述

答案3

以下是基于的解决方案makecell,具有一些颜色和相等高度的行(通过反复试验):

\documentclass[svgnames, table]{article}
\usepackage[utf8]{inputenc}
\usepackage{array, makecell, booktabs}
\usepackage{xcolor}
\newcommand\mystrut{\rule[-2ex]{0pt}{24pt}}

\begin{document}

\begin{center}
  \sffamily\renewcommand\theadfont{\normalsize\bfseries}
  \setcellgapes{5pt}\makegapedcells
  \setlength\tabcolsep{3pt}
  \setlength{\fboxsep}{0pt}
  \arrayrulecolor{Gainsboro}
  \fbox{\begin{tabular}{ *{5}{c|}c}%{ |*{5}{c!{\color{Gainsboro}\vrule width0.4pt}}c}
      \thead{Framework} & \thead{Linguaggio} & \thead{Licenza} & \thead{Prerequisiti} & \thead{Tipologia} \\
      \Xhline{0.4pt}
      \mystrut Pybossa & Python & Open Source & & Applicazioni Web \\
      \hline
      \mystrut CrowdThruth & PHP & Open source & & Applicazioni Web \\
      \hline
      Ionic & Angularjs & Open source & \makecell{Node.js \\ Apache Cordova}
                           & \makecell{Native \\ Cross Platform}\\
      \hline
      \makecell{Appcelerator \\ Titanium} & Javascript & Open Source & \makecell{Node.js\\
      Java} & Cross platform \\
      \hline
      Xamarin & C\# & Open Source & Visual Studio & \makecell{Native \\Cross Platform} \\
      \hline
      \mystrut Django & Python & Open Source & Python & Applicazioni web \\\arrayrulecolor{black}
    \end{tabular}}
\end{center}

\end{document} 

在此处输入图片描述

相关内容