Latex:无法在带有```\\```的公式中显示换行符

Latex: fail to show line breaks in formula with ```\\```

我正在使用 rmarkdown 编织成 pdf。但是,换行符 \ 不生效。我怀疑我的包 amsmath 有问题,因为 运行 tex 文件也显示了同样的问题。但是我不知道怎么解决。

(我用tinytex安装了R和Rstudio,然后安装了tex live 2021,不知道是不是这个原因。)

代码如下:

---
title: "test"
date: '2022-04-07'
output:
  word_document: default
  pdf_document:
    keep_tex: yes
---

$$
a = b \
c = d
$$

此外,当我尝试编织 word 时,出现警告消息

[WARNING] Could not convert TeX math a = b \ c = d , rendering as TeX: a = b \ ^ unexpected control sequence \ expecting "%", "\label", "\tag", "\nonumber" or whitespace

构建 tex 文件,我仍然无法在输出 pdf 中看到预期的换行符。 tex文件如下图

% Options for packages loaded elsewhere
\PassOptionsToPackage{unicode}{hyperref}
\PassOptionsToPackage{hyphens}{url}
%
\documentclass[
]{article}
\usepackage{amsmath,amssymb}
\usepackage{lmodern}
\usepackage{iftex}
\ifPDFTeX
  \usepackage[T1]{fontenc}
  \usepackage[utf8]{inputenc}
  \usepackage{textcomp} % provide euro and other symbols
\else % if luatex or xetex
  \usepackage{unicode-math}
  \defaultfontfeatures{Scale=MatchLowercase}
  \defaultfontfeatures[\rmfamily]{Ligatures=TeX,Scale=1}
\fi
% Use upquote if available, for straight quotes in verbatim environments
\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
\IfFileExists{microtype.sty}{% use microtype if available
  \usepackage[]{microtype}
  \UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts
}{}
\makeatletter
\@ifundefined{KOMAClassName}{% if non-KOMA class
  \IfFileExists{parskip.sty}{%
    \usepackage{parskip}
  }{% else
    \setlength{\parindent}{0pt}
    \setlength{\parskip}{6pt plus 2pt minus 1pt}}
}{% if KOMA class
  \KOMAoptions{parskip=half}}
\makeatother
\usepackage{xcolor}
\IfFileExists{xurl.sty}{\usepackage{xurl}}{} % add URL line breaks if available
\IfFileExists{bookmark.sty}{\usepackage{bookmark}}{\usepackage{hyperref}}
\hypersetup{
  pdftitle={test},
  hidelinks,
  pdfcreator={LaTeX via pandoc}}
\urlstyle{same} % disable monospaced font for URLs
\usepackage[margin=1in]{geometry}
\usepackage{graphicx}
\makeatletter
\def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth\else\Gin@nat@width\fi}
\def\maxheight{\ifdim\Gin@nat@height>\textheight\textheight\else\Gin@nat@height\fi}
\makeatother
% Scale images if necessary, so that they will not overflow the page
% margins by default, and it is still possible to overwrite the defaults
% using explicit options in \includegraphics[width, height, ...]{}
\setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio}
% Set default figure placement to htbp
\makeatletter
\def\fps@figure{htbp}
\makeatother
\setlength{\emergencystretch}{3em} % prevent overfull lines
\providecommand{\tightlist}{%
  \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
\setcounter{secnumdepth}{-\maxdimen} % remove section numbering
\ifLuaTeX
  \usepackage{selnolig}  % disable illegal ligatures
\fi

\title{test}
\author{}
\date{\vspace{-2.5em}2022-04-07}

\begin{document}
\maketitle

\[
a = b \
c = d
\]

\end{document}

我认为这应该可以完美地回答您的问题: https://tex.stackexchange.com/questions/46189/how-do-i-add-a-line-break-in-display-math-mode

简而言之\[ \] 是为 equation/one 一行数学而写的。要添加 line-break,您应该使用像 gatheralign 这样的环境。 align 的代码在您的 tex-code 中看起来像这样:

\begin{align}
    a &= b \        
    c &= d
\end{align}

如果您不需要对方程式进行编号,您可以使用相应环境的星号版本(gather*align*。像这样:

\begin{align*}
    a &= b \        
    c &= d
\end{align*}

如果我提供的link不符合您的问题,请说明原因。我很乐意纠正这个答案。