如何修改下表

如何修改下表

在下面的例子中,您可能会看到我有一张表格:

我想改变/引入并了解以下内容:

  1. 如何将列分隔符改为。通常,当列指定为等时\Rightarrow,可以通过引入来实现这一点。但是在“段落模式”中,如何做到这一点?在这种情况下,隐含符号 ( ) 向上移动。@{$\Rightarrow$}{cc}\Rightarrow
  2. 如何确保表格行的编号(2)(3)与主编号对齐(之前的顶部(1)
  3. 如何在第 2 列中引入对齐环境(示例中已注释掉)?

\documentclass[leqno,10pt]{article}
\usepackage{soul}
\usepackage[margin=0.75in]{geometry}
\def\changemargin#1#2{\list{}{\rightmargin#2\leftmargin#1}\item[]}
\let\endchangemargin=\endlist 
\usepackage{fancyhdr}
\pagestyle{fancy}
\lhead{Lecture 1}
\rhead{Handout 3}
\usepackage{mathtools}
\usepackage{enumitem,array}
\usepackage{relsize}
\usepackage{amsmath}
\usepackage{amsthm} %for proof 
\newtheorem*{mythm}{Theorem}
\newtheorem*{mydef}{Definition}
\title{\ul{Conditional Expectations in Bivariate Probability Distribution}}
\date{}
\newenvironment{mydescription}{%
   \renewcommand\descriptionlabel[1]{\hspace{\labelsep}\textbf{{##1}}}%
   \begin{description}%
}{%
   \end{description}%
}
\newenvironment{definition}[1][Definition]{\begin{trivlist}
\item[\hskip \labelsep {\bfseries #1}]}{\end{trivlist}}
\begin{document}

\newenvironment{Myitemize}{%
\renewcommand{\labelitemi}{{}}%
\begin{itemize}[nosep]}{\end{itemize}}

\maketitle

\newcommand{\myitem}{\stepcounter{enumi}\item[(\theenumi)]}%for enumerate with no. in brackets
\newcommand\litem[1]{\item{\bfseries {#1}}}

\thispagestyle{fancy}

\begin{definition} 
If the random vector $(X,Y)$ has joint \textbf{pdf} $f(x,y)$ with conditional \textbf{pdf} $g_{2}(y|x)$, and if $Z=h(X,Y)$ is a (single-valued) function of (X,Y). Then the conditional expectation of the random variable $Z$, given $X=x$ is 
\begin{equation}
E(Z|x)=\int_{-\infty}^{\infty}{h(x,y)g_{2}(y|x)dy}
\label{eq:}
\end{equation}
\end{definition}    

\begin{mydescription}
\item[Special cases] (a,b,c are constants; ($X^{*}=X-E(X); Y^{*}=Y-E(Y)$)\\
\begin{tabular}[t]{>{\raggedright\arraybackslash}p{\dimexpr0.5\textwidth-2\tabcolsep-2\arrayrulewidth\relax}@{$\Rightarrow$}
                   >{\raggedright\arraybackslash}p{\dimexpr0.5\textwidth-2\tabcolsep-2\arrayrulewidth\relax}}
\begin{enumerate}[nosep,leftmargin=*,series=mylist,label=(\arabic{enumi}),start=2]
    \item $Z=a+bX+cY$
    \end{enumerate} &
    \begin{Myitemize}
      \item abc %\begin{align*}E(Z|x)&=E(a|x)+b.E(X|x)+c.E(Y|x)\\&=a+bx+c.E(Y|x) \end{align*}
    \end{Myitemize}\\[-3ex]
    \begin{enumerate}[nosep,resume*=mylist]
      \item $Z=XY$
    \end{enumerate} &
    \begin{Myitemize}
      \item def
    \end{Myitemize}\\[-3ex]
    \begin{enumerate}[nosep,resume*=mylist]
      \item $Z=Y$
    \end{enumerate}&
    \begin{Myitemize}
      \item 123
    \end{Myitemize}\\[-3ex]
  \begin{enumerate}[nosep,resume*=mylist]
      \item $Z=(Y-\mu_{Y|X})^{2}$
    \end{enumerate} &
    \begin{Myitemize}
      \item 456
    \end{Myitemize}\\[-3ex]
        \begin{enumerate}[nosep,resume*=mylist]
      \item $Z=(Y-\mu_{Y})^{2}$
    \end{enumerate} &
    \begin{Myitemize}
      \item 789
    \end{Myitemize}\\[-3ex]
    \end{tabular}
\end{mydescription}
\end{document}

答案1

这里有两种方法,首先\mycasesdefinition的样式定义环境amsthm,然后以两种方式将方程式对齐到左边距 — 一种定义tabenum每次\tabitem调用命令时都会增加的计数器(并且可以交叉引用);另一种仅使用环境flalign,因此方程式的编号遵循文档中方程式的一般编号。以下代码可让您比较这两种方式 — 如果第二列有对齐的方程式,则实际上是三种方式。我为条件预期值添加了一个宏,大量借鉴了文档的 §3.6 mathtools,它具有更好的间距和分隔符,可以自动调整到参数的大小(使用 * 版本):

\documentclass[leqno,10pt]{article}
\usepackage{soul}
\usepackage[margin=0.75in]{geometry}

\usepackage{fancyhdr}
\pagestyle{fancy}
\lhead{Lecture 1}
\rhead{Handout 3}
\usepackage{mathtools}
\usepackage{array}
\usepackage{amsthm} %for proof
\newtheorem*{mythm}{Theorem}
\theoremstyle{definition}
\newtheorem*{mydef}{Definition}
\newtheorem*{mycases}{Special cases}
\title{\ul{Conditional Expectations in Bivariate Probability Distribution}}
\date{}
\author{}

\usepackage{tabularx}

\providecommand\given{}
\DeclarePairedDelimiterXPP\EV[1]{E}(){}{
\renewcommand\given{\nonscript\,\delimsize\vert\nonscript\,}
#1}

\begin{document}

\newenvironment{Myitemize}{%
\renewcommand{\labelitemi}{{}}%
\begin{itemize}[nosep]}{\end{itemize}}

\maketitle

\newcommand{\myitem}{\stepcounter{enumi}\item[(\theenumi)]}%for enumerate with no. in brackets
\newcommand\litem[1]{\item{\bfseries {#1}}}

\thispagestyle{fancy}

\begin{mydef}
If the random vector $(X,Y)$ has joint \textbf{pdf} $f(x,y)$ with conditional \textbf{pdf} $g_{2}(y|x)$, and if $Z=h(X,Y)$ is a (single-valued) function of (X,Y). Then the conditional expectation of the random variable $Z$, given $X=x$ is
\begin{equation}
\EV{Z \given x} = =\int_{-\infty}^{\infty}{h(x,y)g_{2}(y|x)dy}
\label{eq:}
\end{equation}
\end{mydef}

\begin{mycases}
(a,b,c are constants; ($X^{*}=X-E(X); Y^{*}=Y-E(Y)$)\\
%

\newcounter{tabenum}\setcounter{tabenum}{1}
\newcommand{\tabitem}{\refstepcounter{tabenum}(\thetabenum)}
\renewcommand\arraystretch{1.25}\noindent
\begin{tabularx}{\linewidth}{@{}l@{\enspace}>{\raggedright\arraybackslash $}X <{$}
 !{{} $ \Rightarrow ${}} >{\raggedright\arraybackslash}X}
\tabitem & Z=a+bX+cY & $ \begin{aligned}[t]\EV{Z \given x}&=\EV{a \given x}+b.\EV{X \given x}+c.\EV{Y \given x}\\&=a+bx+c.\EV{Y \given x} \end{aligned}$\\
\tabitem & Z=XY &def \\
\tabitem & Z=Y & 123 \\
\tabitem & Z=(Y-\mu_{Y|X})^{2} & 456 \\
\tabitem & Z=(Y-\mu_{Y})^{2} & 789
 \end{tabularx}

\begin{flalign}\label{cas}
    & Z=a+bX+cY & \Rightarrow\quad & \!\begin{aligned}[t]\EV{Z \given x}&=\EV{a \given x}+b.\EV{X \given x}+c.\EV{Y \given x} \\&= a+bx+c.\EV{Y \given x} \end{aligned} &\hphantom{Z=a+bX+cY\quad(2)} & \\
   & Z=XY & \Rightarrow\quad & \text{def} \\
 & Z = Y & \Rightarrow\quad & 123 \\
 & Z=(Y-\mu_{Y|X})^{2} &\Rightarrow\quad & 456 \\
 & Z=(Y-\mu_{Y})^{2} & \Rightarrow\quad & 789
\end{flalign}

\begin{flalign}\label{cas}
    & Z=a+bX+cY & \Rightarrow\quad & \!\begin{aligned}[t]\EV{Z \given x}&=\mathrlap{\EV{a \given x}+b.\EV{X \given x}+c.\EV{Y \given x}}\\&=\mathrlap{a+bx+c.\EV{Y \given x}} \end{aligned} &\hphantom{Z=a+bX+cY\quad(2)} & \\
   & Z=XY & \Rightarrow\quad & \text{def} \\
 & Z = Y & \Rightarrow\quad & 123 \\
 & Z=(Y-\mu_{Y|X})^{2} &\Rightarrow\quad & 456 \\
 & Z=(Y-\mu_{Y})^{2} & \Rightarrow\quad & 789
\end{flalign}
\end{mycases}

\end{document} 

在此处输入图片描述

相关内容