在下表中,我想仅左对齐三个单元格:单元格 1、单元格 1000 和单元格 100,000。这可能吗?
\documentclass[12pt]{article}
\usepackage{graphicx}
\usepackage{threeparttable}
\usepackage{color, colortbl}
\definecolor{Gray}{gray}{0.9}
\usepackage{multirow}
\title{Question}
\begin{document}
\maketitle
This is the content of this document.
\begin{table}[h!]
\centering
\caption {Mixture samples Set 1} \label{mixset1}
\begin{tabular}{ccc}
{\bf{Mixture}} & \multirow{2}{*}{\bf{Total (pg)}} & {\bf{Minor Contributor}} \\
{\bf{Ratios}} &{} &{\bf{DNA (pg)}} \\
\cellcolor{Gray}{4:3:2:1} & \cellcolor{Gray}{cell1} & \cellcolor{Gray}{100, 50, 25, 12.5, 6.25} \\
{10:5:2:1} & {cell1000} &
{100, 50, 25, 12.5, 6.25} \\
\cellcolor{Gray}{10:5:1} & \cellcolor{Gray}{cell100,000} & \cellcolor{Gray}{100, 50, 25, 12.5, 6.25} \\
\end{tabular}
\end{table}
\end{document}
答案1
要仅左对齐一个单元格,您可以使用\multicolumn{1}{l}{<cell contents>}
。此外,由于您有带灰色背景的完整行,您可以\rowcolor{Gray}
在相应行之前发出一个命令来节省输入时间。
\documentclass[12pt]{article}
\usepackage{graphicx}
\usepackage{threeparttable}
\usepackage{color, colortbl}
\definecolor{Gray}{gray}{0.9}
\usepackage{multirow}
\title{Question}
\begin{document}
\maketitle
This is the content of this document.
\begin{table}[h!]
\centering
\caption{Mixture samples Set 1} \label{mixset1}
\begin{tabular}{ccc}
\textbf{Mixture} & \multirow{2}{*}{\textbf{Total (pg)}} & \textbf{Minor Contributor} \\
\textbf{Ratios} & {} & \textbf{DNA (pg)} \\ \rowcolor{Gray}
4:3:2:1 & \multicolumn{1}{l}{cell1} & 100, 50, 25, 12.5, 6.25 \\
10:5:2:1 & \multicolumn{1}{l}{cell1000} & 100, 50, 25, 12.5, 6.25 \\ \rowcolor{Gray}
10:5:1 & \multicolumn{1}{l}{cell100,000} & 100, 50, 25, 12.5, 6.25 \\
\end{tabular}
\end{table}
\end{document}
答案2
一些评论:
- 使用
\bf
折旧年限为 + 20 年 - 单元格内容不需要用花括号括起来
- 用于行着色的宏/命令
\rowcolor
- 使用
makecell
前两行可以合并为一行
MWE(仅适用于表格):
\documentclass[12pt]{article}
\usepackage{graphicx}
\usepackage{makecell}
\renewcommand\theadfont{\bfseries\normalsize}
\usepackage[table]{xcolor}
\definecolor{Gray}{gray}{0.9}
\begin{document}
\begin{table}[h!]
\centering
\caption {Mixture samples Set 1} \label{mixset1}
\begin{tabular}{clc}
\thead{Mixture\\Ratios}
& \thead{Total (pg)}
& \thead{Minor\\ Contributor} \\
\rowcolor{Gray}
4:3:2:1 & cell1 & 100, 50, 25, 12.5, 6.25 \\
10:5:2:1 & cell1000 & 100, 50, 25, 12.5, 6.25 \\
\rowcolor{Gray}
10:5:1 & cell100,000 & 100, 50, 25, 12.5, 6.25 \\
\end{tabular}
\end{table}
\end{document}
答案3
是的。只需将单元格的说明符更改为{clc}
,您的行就会居中-左-居中对齐。有关如何指定列对齐的更多信息,请参见此处:Latex 维基。
这也会将表格的标题左对齐,但在您的示例中几乎看不到它,而且如果标题的对齐方式与单元格不同,它看起来会很奇怪
\documentclass[12pt]{article}
\usepackage{graphicx}
\usepackage{threeparttable}
\usepackage{color, colortbl}
\definecolor{Gray}{gray}{0.9}
\usepackage{multirow}
\title{Question}
\begin{document}
\maketitle
This is the content of this document.
\begin{table}[h!]
\centering
\caption {Mixture samples Set 1} \label{mixset1}
\begin{tabular}{clc} % <==== here's the important change
{\bf{Mixture}} & \multirow{2}{*}{\bf{Total (pg)}} & {\bf{Minor Contributor}} \\
{\bf{Ratios}} &{} &{\bf{DNA (pg)}} \\
\cellcolor{Gray}{4:3:2:1} & \cellcolor{Gray}{cell1} & \cellcolor{Gray}{100, 50, 25, 12.5, 6.25} \\
{10:5:2:1} & {cell1000} &
{100, 50, 25, 12.5, 6.25} \\
\cellcolor{Gray}{10:5:1} & \cellcolor{Gray}{cell100,000} & \cellcolor{Gray}{100, 50, 25, 12.5, 6.25} \\
\end{tabular}
\end{table}
\end{document}