我正在逐字环境中渲染内联数学。
其代码为
\usepackage{upquote} % Upright quotes for verbatim code
\usepackage{eurosym} % defines \euro
\usepackage[mathletters]{ucs} % Extended unicode (utf-8) support
\usepackage[utf8x]{inputenc} % Allow utf-8 characters in the tex document
\usepackage{fancyvrb} % verbatim replacement that allows latex
\providecommand{\tightlist}{%
\setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
\DefineVerbatimEnvironment{Highlighting}{Verbatim}{commandchars=\\\{\}}
\begin{Verbatim}[commandchars=\\\{\}, fontsize=\small, xleftmargin=-3.9em]
\displaystyle \cos{\left(x \right)} - (1)
\end{Verbatim} - (2)
对于第(1)行,警告为-缺少$。额外},或忘记了$。
对于第(2)行,警告为-发生了错误-可能缺少\ item。缺少$。缺少}。
如果有人想现场观看此视频,请参阅下面的链接(只读):-https://www.overleaf.com/read/dvrbkmkmdcgc
我无法找出此处所需的正确语法。 谢谢。
答案 0 :(得分:1)
您需要在嵌入式数学周围添加数学模式。在普通文本中,您可能会使用$...$
,但是由于已经启用\
作为乳胶命令的开始而转义,因此可以使用\(....\)
作为快速解决方法。如果您需要更大的灵活性,建议不要使用listings
,而是使用fancyvrb
软件包。
\documentclass{article}
\usepackage{upquote} % Upright quotes for verbatim code
\usepackage{eurosym} % defines \euro
\usepackage[mathletters]{ucs} % Extended unicode (utf-8) support
\usepackage[utf8x]{inputenc} % Allow utf-8 characters in the tex document
\usepackage{fancyvrb} % verbatim replacement that allows latex
\providecommand{\tightlist}{%
\setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
\DefineVerbatimEnvironment{Highlighting}{Verbatim}{commandchars=\\\{\}}
\title{Testing}
\author{aakashguptachoudhury }
\date{October 2019}
\usepackage{natbib}
\usepackage{graphicx}
\begin{document}
\maketitle
\section{Introduction}
There is a theory which states that if ever anyone discovers exactly what the Universe is for and why it is here, it will instantly disappear and be replaced by something even more bizarre and inexplicable.
There is another theory which states that this has already happened.
\begin{figure}[h!]
\centering
\includegraphics[scale=1.7]{universe}
\caption{The Universe}
\label{fig:universe}
\end{figure}
\section{Conclusion}
``I always thought something was fundamentally wrong with the universe'' \citep{adams1995hitchhiker}
\begin{Verbatim}[commandchars=\\\{\}, fontsize=\small, xleftmargin=-3.9em]
\(\displaystyle \displaystyle \cos{\left(x\right)} \)
\end{Verbatim}
\bibliographystyle{plain}
\bibliography{references}
\end{document}