我正在使用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
$$
此外,当我尝试编织单词时,会出现警告消息
[警告]无法转换TeX数学a=b\c=d,渲染为TeX:a=b\^意外控制序列\期望"%"&"\标签"\标签"\非成员;或空白
在构建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
defmaxwidth{ifdimGin@nat@width>linewidthlinewidthelseGin@nat@widthfi}
defmaxheight{ifdimGin@nat@height>textheighttextheightelseGin@nat@heightfi}
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
deffps@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
简而言之:[ ]
是为一个方程/一行数学而生成的。要添加换行符,应该使用类似gather
或align
的环境。align
的代码在您的tex代码中是这样的:
begin{align}
a &= b \
c &= d
end{align}
如果你不需要对方程进行编号,你可以使用相应环境的星形版本(gather*
,align*
begin{align*}
a &= b \
c &= d
end{align*}
如果我提供的链接不适合您的问题,请解释原因。我很高兴更正这个答案。