![2x2 表格的中心标题](https://linux22.com/image/374695/2x2%20%E8%A1%A8%E6%A0%BC%E7%9A%84%E4%B8%AD%E5%BF%83%E6%A0%87%E9%A2%98.png)
在我的 2x2 表格中,我想将标题“Ashley”和“Matt”定位为始终相对于文本相邻列居中。我附上了一张理想位置的图片(红色框)。
这可能吗?
梅威瑟:
\documentclass[a4paper,12pt]{article}
\usepackage{graphicx}
\usepackage[main=british]{babel}
%\usepackage{gensymb}
\usepackage[section]{placeins}%Allows you to permanently fix figures.
\usepackage[left=2.5cm, right=2.5cm, top=3.5cm, bottom=3.5cm]{geometry}%this changes the page geometry i.e. margins left, right, top and bottom
%\usepackage{caption}
\usepackage{mathptmx}
%\usepackage{newtxmath}
\usepackage{titleps,microtype,setspace,amsmath,SIunits,tabularx}
\usepackage{booktabs,caption, makecell,ltablex}
\usepackage{pdflscape,afterpage}
\usepackage[backend=bibtex, citestyle=ieee, bibstyle=ieee]{biblatex}
\addbibresource{library}
\onehalfspacing
\renewcommand\theadfont{\small\bfseries}
\renewcommand\tabularxcolumn[1]{m{#1}}
\usepackage[usestackEOL]{stackengine}
\usepackage[table]{xcolor}
\usepackage{enumitem}
\usepackage{etoolbox}
\AtBeginEnvironment{table}{%
\setlist[enumerate]{nosep,
topsep = 0pt,
partopsep = 0pt,
leftmargin = *,
before = \vspace{-0.6\baselineskip},
after = \vspace{-\baselineskip}
}}
\keepXColumns
\begin{document}
\begin{tabular}{ r p{50mm} p{50mm}}
\cline{2-3}
\multicolumn{1}{r}{}
& \multicolumn{1}{c}{Heading}
& \multicolumn{1}{c}{Heading} \\
\cline{2-3}
Ashley & There is virtually no feedback given by the interface during use. \par There is virtually no feedback given by the interface during use. & There is virtually no feedback given by the interface during use. There is virtually no feedback given by the interface during use. \\
%cline{1-3}
Matt & There is virtually no feedback given by the interface during use. \par There is virtually no feedback given by the interface during use. & There is virtually no feedback given by the interface during use. \par There is virtually no feedback given by the interface during use. \\
\cline{2-3}
\end{tabular}
\begin{table}[ht]
\caption{Cognitive walkthrough goals, tasks and actions}
\label{table:comparison of techniques}
\small
\begin{tabularx}{\linewidth}{@{}
X
>{\centering\arraybackslash}X % content of `X` column is now centered
X
@{}}
\toprule
\thead{\textbf{Goal}}& \thead{\textbf{Task}} & \thead{\textbf{Action}} \\
\midrule
Evaluate the ease in which users can join projects
& Task 1: Access and account set up
& \begin{enumerate}
\item Text.
Text.
\item Join the project.
\end{enumerate} \\
\addlinespace
Evaluate the ease in learning to map
& Task 2: Learning how to map
& Read tutorial \\
\addlinespace
Contribute data
& Task 3: Contributing data by classifying maps
& \begin{enumerate}
\item Begin mapping.
\item Text.
Text.
\item Review maps classified.
\end{enumerate} \\
\addlinespace
Evaluate if the user likes using the application and whether they like using it
& -- & -- \\
\bottomrule
\vspace{-18mm}%needed otherwise the table gets lost between pagebreaks.
\end{tabularx}
\end{table}
\end{document}
提前致谢!
答案1
而不是p{...}
列类型使用m{...}
:
\documentclass[a4paper,12pt]{article}
\usepackage{graphicx}
%\usepackage[main=british]{babel}
%\usepackage{gensymb}
\usepackage[section]{placeins}%Allows you to permanently fix figures.
\usepackage[hmargin=2.5cm, vmargin=3.5cm]{geometry}%this changes the page geometry i.e. margins left, right, top and bottom
%\usepackage{caption}
\usepackage{mathptmx}
%\usepackage{newtxmath}
\usepackage{titleps,microtype}
\usepackage{setspace, amsmath, siunitx}% SIunits is consider obsolete
\usepackage{booktabs, ltablex, makecell}
\usepackage{caption}
\usepackage{pdflscape,afterpage}
%\usepackage[backend=bibtex, citestyle=ieee, bibstyle=ieee]{biblatex}
%\addbibresource{library}
\onehalfspacing
\renewcommand\theadfont{\small\bfseries}
\renewcommand\tabularxcolumn[1]{m{#1}}
\usepackage[usestackEOL]{stackengine}
\usepackage[table]{xcolor}
\usepackage{enumitem}
\usepackage{etoolbox}
\AtBeginEnvironment{table}{%
\setlist[enumerate]{nosep,
topsep = 0pt,
partopsep = 0pt,
leftmargin = *,
% before = \vspace{-0.6\baselineskip},
after = \vspace{-\baselineskip}
}}
\keepXColumns
\begin{document}
\begin{tabular}{r m{50mm} m{50mm}}
\cline{2-3}
\multicolumn{1}{r}{}
& \multicolumn{1}{c}{Heading}
& \multicolumn{1}{c}{Heading} \\
\cline{2-3}
Ashley
& There is virtually no feedback given by the interface during use. \par
There is virtually no feedback given by the interface during use. & There is virtually no feedback given by the interface during use. There is virtually no feedback given by the interface during use. \\
%cline{1-3}
Matt
& There is virtually no feedback given by the interface during use. \par
There is virtually no feedback given by the interface during use. & There is virtually no feedback given by the interface during use. \par
There is virtually no feedback given by the interface during use. \\
\cline{2-3}
\end{tabular}
\begin{table}[ht]
\caption{Cognitive walkthrough goals, tasks and actions}
\label{table:comparison of techniques}
\small
\begin{tabularx}{\linewidth}{@{}
X
>{\centering\arraybackslash}X % content of `X` column is now centered
X
@{}}
\toprule
\thead{Goal} & \thead{Task} & \thead{Action} \\
\midrule
Evaluate the ease in which users can join projects
& Task 1: Access and account set up
& \begin{enumerate}
\item Text.
Text.
\item Join the project.
\end{enumerate} \\
\addlinespace
Evaluate the ease in learning to map
& Task 2: Learning how to map
& Read tutorial \\
\addlinespace
Contribute data
& Task 3: Contributing data by classifying maps
& \begin{enumerate}
\item Begin mapping.
\item Text.
Text.
\item Review maps classified.
\end{enumerate} \\
\addlinespace
Evaluate if the user likes using the application and whether they like using it
& -- & -- \\
\bottomrule
\vspace{-18mm}%needed otherwise the table gets lost between pagebreaks.
\end{tabularx}
\end{table}
\end{document}