将 Parskip 放入表格中

将 Parskip 放入表格中

我正在尝试将 parskip 添加到文档中的表格中。在我的所有文本中,parskip 都可以正常工作,但它似乎无法在表格单元格内工作。有人能解释一下如何让它工作吗?

代码如下:

\documentclass[11pt]{article}
\usepackage[british,UKenglish,english]{babel}
\usepackage[a4paper, total={6in, 8in}, margin=0.8in]{geometry}
\usepackage{caption}
\usepackage{color, colortbl}
\usepackage{array}
\usepackage{parskip}
\usepackage{float}
\setcounter{secnumdepth}{4}
\usepackage{pgfgantt}
\usepackage{lscape}
%\graphicspath{ {./images/} }
\renewcommand{\familydefault}{\sfdefault}

\newcolumntype{P}[1]{>{\centering\arraybackslash}p{#1}}
\renewcommand{\arraystretch}{1.2}

\begin{document}
    \begin{table*}[ht]
        \centering
        \begin{tabular}{|>{ \centering \arraybackslash}P{4cm}|m{12cm}|}
            \hline
            \multicolumn{1}{|>{ \centering\arraybackslash}m{4cm}|}{ \color{white} Aim \cellcolor{black}}
            & \multicolumn{1}{>{\centering\arraybackslash}m{12cm}|}{ \color{white} Explanation \cellcolor{black}} \\
            \hline
            Aim 1
            & 
            Lorem Ipsum is simply dummy text of the printing and typesetting industry. 
            
            Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. \\
            \hline
            Aim 2
            &
            Lorem Ipsum is simply dummy text of the printing and typesetting industry. 
            
            Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. \\
            \hline
        \end{tabular}
        \caption{Overview of Aims}
        \label{table:1}
    \end{table*}
\end{document}

谢谢!

答案1

除了添加之外>{\setlength{\parskip}{0.5\baselineskip}},我还使用了tabularx包以确保您的表格适合边距。

在此处输入图片描述

\documentclass[11pt]{article}
\usepackage[UKenglish]{babel}
\usepackage[a4paper, total={6in, 8in}]{geometry}
\usepackage{caption}
\usepackage[table]{xcolor} % instead of color and colortbl
\usepackage{array}
\usepackage{parskip}
\usepackage{float}
\setcounter{secnumdepth}{4}
\usepackage{pgfgantt}
\usepackage{lscape}
%\graphicspath{ {./images/} }
\renewcommand{\familydefault}{\sfdefault}
\newcolumntype{P}[1]{>{\centering\arraybackslash}p{#1}}

\renewcommand{\arraystretch}{1.2}
\usepackage{tabularx}
\renewcommand{\tabularxcolumn}[1]{m{#1}}
\begin{document}
 \begin{table*}[ht]
            \centering
            \begin{tabularx}{\textwidth}{|l|>{\setlength{\parskip}{0.5\baselineskip}}X|}
                \hline
                \multicolumn{1}{|c|}{ \color{white} Aim \cellcolor{black}}
                & \multicolumn{1}{c|}{ \color{white} Explanation \cellcolor{black}} \\
                \hline
                Aim 1
                & 
  
    Lorem Ipsum is simply dummy text of the printing and typesetting industry. 
    
    Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. \\
                \hline
                Explanation
                &

    Lorem Ipsum is simply dummy text of the printing and typesetting industry. 
        
        Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. \\
                \hline
            \end{tabularx}
        \caption{Overview of Aims}
            \label{table:1}
        \end{table*}
        
        \end{document}

相关内容