Tabularx 方程式不合时宜

Tabularx 方程式不合时宜

有人能告诉我为什么下面两个方程垂直方向不对齐吗?右边的方程向下对齐,我不知道为什么!

\documentclass[12pt]{article}
\usepackage{amsmath, amssymb, hyperref, amsthm, geometry, amsfonts, enumitem, mathtools, upgreek, multicol, tabularx}
\usepackage[numbers]{natbib}
\usepackage[toc,page]{appendix}
\bibliographystyle{plainnat}
\setlength{\parindent}{0pt}
\newtheorem{theorem}{Theorem}[section]
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{proposition}[theorem]{Proposition}
\newtheorem{corollary}[theorem]{Corollary}
\newtheorem*{aoc}{Axiom of Choice}


\theoremstyle{definition}
\newtheorem{definition}[theorem]{Definition}

\theoremstyle{remark}
\newtheorem{remark}[theorem]{Remark}
\newtheorem{example}[theorem]{Example}

\setlength{\textwidth}{15cm}

\allowdisplaybreaks


\begin{document}
\begin{tabularx}{\linewidth}{@{}XX@{}}
\begin{equation} \nonumber
\varphi(g)^{+}=\begin{cases}
    \varphi(g), & \text{if $\varphi(g)\geq 0$}.\\
    0, & \text{otherwise}.
  \end{cases}
\end{equation}
&
\begin{equation} \nonumber
  \varphi(g)^{-}=\begin{cases}
    -\varphi(g), & \text{if $\varphi(g)\leq 0$}.\\
    0, & \text{otherwise}.
  \end{cases}
\end{equation}
\end{tabularx}
\end{document}

在此处输入图片描述

答案1

问题出在geometry包中。相反,你使用

\usepackage{amsmath, amssymb, hyperref, amsthm, geometry, amsfonts, enumitem, mathtools, upgreek, multicol, tabularx}
 ...
\setlength{\textwidth}{15cm}

尝试使用以下方式重新排列你的序言:

\documentclass[12pt]{article}
\usepackage[margin=30mm]{geometry}  % <--- you should add `margin`
\setlength{\parindent}{0pt}
\usepackage{mathtools, amssymb, amsthm}

\newtheorem{theorem}{Theorem}[section]
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{proposition}[theorem]{Proposition}
\newtheorem{corollary}[theorem]{Corollary}
\newtheorem*{aoc}{Axiom of Choice}

\theoremstyle{definition}
\newtheorem{definition}[theorem]{Definition}

\theoremstyle{remark}
\newtheorem{remark}[theorem]{Remark}
\newtheorem{example}[theorem]{Example}

\allowdisplaybreaks
\usepackage[numbers]{natbib}
\usepackage[toc,page]{appendix}
\bibliographystyle{plainnat}

\usepackage{tabularx}
\usepackage{enumitem}
\usepackage{hyperref}   % had to be loaded last

其结果是:

在此处输入图片描述

答案2

罪魁祸首似乎是\nonumber,所以我会使用equation*环境。

无关:不用装amsfonts就装amssymbamsmath装了就不用装mathtools

\documentclass[12pt]{article}
\usepackage{amssymb, hyperref, amsthm, geometry, enumitem, mathtools, upgreek, multicol, tabularx}

\setlength{\textwidth}{15cm}

\allowdisplaybreaks

\begin{document}

\begin{tabularx}{\linewidth}{XX}
\begin{equation*}
  \varphi(g)^{+}=\begin{cases}
    \varphi(g), & \text{if $\varphi(g)\geq 0$}.\\
    0, & \text{otherwise}.
  \end{cases}
\end{equation*}
&
\begin{equation*}
  \varphi(g)^{+}=\begin{cases}
    \varphi(g), & \text{if $\varphi(g)\geq 0$}.\\
    0, & \text{otherwise}.
  \end{cases}
\end{equation*}
\end{tabularx}
\vskip 3ex

\begin{tabularx}{\linewidth}{XX}
\begin{equation}\nonumber
  \varphi(g)^{+}=\begin{cases}
    \varphi(g), & \text{if $\varphi(g)\geq 0$}.\\
    0, & \text{otherwise}.
  \end{cases}
\end{equation}
&
\begin{equation}\nonumber
  \varphi(g)^{+}=\begin{cases}
    \varphi(g), & \text{if $\varphi(g)\geq 0$}.\\
    0, & \text{otherwise}.
  \end{cases}
\end{equation}
\end{tabularx}

\end{document} 

在此处输入图片描述

相关内容