我的报告中有一个定义列表,现在我已将其对齐,以便定义(右侧)对齐良好。现在我决定在保持对齐的同时在它们之间添加点(类似于目录)。我读过有关表格和使用 \dotfill 的内容,但我无法保持对齐。另外,因为有些定义超过两行。
以下是代码:
\documentclass[a4paper]{report}
\usepackage{bm,bbm}
\usepackage{amsthm}
\usepackage{amsmath}
\usepackage{amssymb}
\begin{document}
\begin{align*}
&\textit{a}&& \text{Allele}\\
&\textit{m} \in \{1,..., M\}&& \text{Marker}\\
&\textit{k} \in \{1,..., K\}&& \text{Contributor}\\
&g_{m,k} = (g_{m,k,1},g_{m,k,2})&& \text{Genotype of contributor $k$ at marker $m$, consisting of two alleles}\\
&\textbf{g}_{m} = (g_{m,1},...,g_{m,K})&& \text{Set of genotypes for all $K$ contributors}\\
&\textbf{A}_m && \text{All alleles at marker $m$ observed in database plus new alleles discovered}\\
&&&\text{when individuals are added}\\
&\textbf{Y}_m && \text{Observed peak heights of the alleles in \textbf{A}}_m\\
& Y_{m,a} && \text{Observed peak height of allele $a$ at marker $m$}\\
& Y_{m,a,k} && \text{Peak height contribution of contributor $k$ to $Y_{m,a}$}\\
& \mathbb{Q}_m = \{(a,b): a,b\in \textbf{A}_m\} && \text{The set of all possible genotypes at marker $m$}\\
&\pi_k && \text{Mixture proportion: proportion of total DNA added by contributor $k$}\\
&\bm{\pi} = (\pi_1, ..., \pi_K)&& \text{Set of mixture proportions for all $K$ contributors}\\
&&&\text{such that }\textstyle\sum_{k=1}^K \pi_k =1 \\
&\textit{$p_a$}&& \text{Population allele frequency of allele $a$}
\end{align*}
\end{document}
结果如下:
因此,我想要在例如 a 和等位基因之间以及 A_m 和“所有等位基因...”之间添加点,以便下一行(“当个体...”)之间没有点
提前致谢!如果我的代码中遗漏了某些内容,请见谅,我并不经常这样做 :)
答案1
您应该使用表格。下面,我使用了{tabularx}
同名包中的表格。
虚线是用命令插入的\dotfill
。
\documentclass[a4paper]{report}
\usepackage{bm,bbm}
\usepackage{amsthm}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{tabularx}
\usepackage{lipsum} % for dummy text
\begin{document}
\lipsum[1]
\bigskip
\noindent
\begin{tabularx}{\linewidth}{>{$}l<{$\enspace\dotfill}>{\raggedright\arraybackslash}X}
a & Allele\\
m \in \{1,..., M\}& Marker\\
k \in \{1,..., K\}& Contributor\\
g_{m,k} = (g_{m,k,1},g_{m,k,2})& Genotype of contributor $k$ at marker $m$, consisting of two alleles\\
\textbf{g}_{m} = (g_{m,1},...,g_{m,K})& Set of genotypes for all $K$ contributors \\
\textbf{A}_m & All alleles at marker $m$ observed in database plus new alleles discovered
when individuals are added\\
\textbf{Y}_m & Observed peak heights of the alleles in $\textbf{A}_m$\\
Y_{m,a} & Observed peak height of allele $a$ at marker $m$\\
Y_{m,a,k} & Peak height contribution of contributor $k$ to~$Y_{m,a}$\\
\mathbb{Q}_m = \{(a,b): a,b\in \textbf{A}_m\} & The set of all possible genotypes at marker $m$\\
\pi_k & Mixture proportion: proportion of total DNA added by contributor $k$\\
\bm{\pi} = (\pi_1, ..., \pi_K)& Set of mixture proportions for all $K$ contributors
such that $\sum_{k=1}^K \pi_k =1$ \\
p_a & Population allele frequency of allele $a$
\end{tabularx}
\end{document}
如果希望不同线的点完美对齐,请替换\dotfill
为\leaders\hbox to 1mm{\hss.\hss}\hfill
:
\documentclass[a4paper]{report}
\usepackage{bm,bbm}
\usepackage{amsthm}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{tabularx}
\usepackage{lipsum} % for dummy text
\begin{document}
\lipsum[1]
\bigskip
\noindent
\begin{tabularx}{\linewidth}{>{$}l<{\enspace$\leaders\hbox to 1mm{\hss.\hss}\hfill}>{\raggedright\arraybackslash}X}
a & Allele\\
m \in \{1,..., M\}& Marker\\
k \in \{1,..., K\}& Contributor\\
g_{m,k} = (g_{m,k,1},g_{m,k,2})& Genotype of contributor $k$ at marker $m$, consisting of two alleles\\
\textbf{g}_{m} = (g_{m,1},...,g_{m,K})& Set of genotypes for all $K$ contributors \\
\textbf{A}_m & All alleles at marker $m$ observed in database plus new alleles discovered
when individuals are added\\
\textbf{Y}_m & Observed peak heights of the alleles in $\textbf{A}_m$\\
Y_{m,a} & Observed peak height of allele $a$ at marker $m$\\
Y_{m,a,k} & Peak height contribution of contributor $k$ to~$Y_{m,a}$\\
\mathbb{Q}_m = \{(a,b): a,b\in \textbf{A}_m\} & The set of all possible genotypes at marker $m$\\
\pi_k & Mixture proportion: proportion of total DNA added by contributor $k$\\
\bm{\pi} = (\pi_1, ..., \pi_K)& Set of mixture proportions for all $K$ contributors
such that $\sum_{k=1}^K \pi_k =1$ \\
p_a & Population allele frequency of allele $a$
\end{tabularx}
\end{document}
答案2
align
绝对不是适合此目的的工具。
我建议采用一种与表格不同的方法,允许分页。
每个条目都通过带有两个参数的命令输入\entry
;第一个参数以数学模式排版,\symbolswd
宽度为一个框;第二个参数以悬挂段落排版,用点引号填充空间。
\symbolswd
计算每个条目的长度并将最终值保存在文件中,.aux
因此在下次运行时所有条目的宽度将相同(如果宽度不同则会发出警告)。
\symbolswd
当环境结束时的值与开始时的值不同时,会发出警告。在这种情况下,重新运行将解决问题。
\documentclass[a4paper]{report}
\usepackage{bm,bbm}
\usepackage{amsthm}
\usepackage{amsmath}
\usepackage{amssymb}
\makeatletter
\newlength{\symbolswd}
\newenvironment{symbols}
{%
\chapter*{Symbols}
\setlength{\parindent}{0pt}%
\edef\current@symbolswd{\the\symbolswd}%
\sloppy
\interlinepenalty=10000 % no page break in a two line entry
}
{%
\ifdim\current@symbolswd=\symbolswd
\else
\@latex@warning@no@line{Rerun to get list of symbols right}%
\fi
\immediate\write\@auxout{\global\symbolswd=\the\symbolswd}%
}
\newcommand{\entry}[2]{%
\par\addvspace{\smallskipamount}
\sbox\z@{$#1$\qquad}%
\ifdim\wd\z@<\symbolswd \setlength{\symbolswd}{\wd\z@}\fi
\hangindent=\symbolswd
\makebox[\symbolswd][s]{$#1$\leaders\hbox to 4pt{\hss.\hss}\hfill}%
#2\par
}
\makeatother
\begin{document}
\begin{symbols}
\entry{a}{Allele}
\entry{m \in \{1,\dots, M\}}{Marker}
\entry{k \in \{1,\dots, K\}}{Contributor}
\entry{g_{m,k} = (g_{m,k,1},g_{m,k,2})}{Genotype of contributor $k$
at marker $m$, consisting of two alleles}
\entry{g_{m} = (g_{m,1},\dots,g_{m,K})}{Set of genotypes for all $K$ contributors}
\entry{\mathbf{A}_m}{All alleles at marker $m$ observed in database
plus new alleles discovered when individuals are added}
\entry{\mathbf{Y}_m}{Observed peak heights of the alleles in $\mathbf{A}_m$}
\entry{Y_{m,a}}{Observed peak height of allele $a$ at marker $m$}
\entry{Y_{m,a,k}}{Peak height contribution of contributor $k$ to $Y_{m,a}$}
\entry{\mathbb{Q}_m = \{(a,b): a,b\in \mathbf{A}_m\}}{The set of all possible
genotypes at marker $m$}
\entry{\pi_k}{Mixture proportion: proportion of total DNA added by contributor $k$}
\entry{\bm{\pi} = (\pi_1,\dots,\pi_K)}{Set of mixture proportions for all $K$ contributors
such that $\sum_{k=1}^K \pi_k =1$}
\entry{p_a}{Population allele frequency of allele $a$}
\end{symbols}
\end{document}