You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

LaTeX listings宏包无法显示单引号与双引号内代码的问题求助

LaTeX listings宏包无法显示单引号与双引号内代码的问题求助

大家好,我最近在LaTeX里用listings宏包展示R代码时遇到了个麻烦——代码里单引号和双引号包裹的内容都没法正常显示出来。

下面是我的最小示例项目代码:

\documentclass[12pt,a4paper,openany,oneside]{book}

\usepackage{listings}

\usepackage{color}

\lstset{
language=R,
basicstyle=\footnotesize\ttfamily,
numbers=left,
numberstyle=\tiny,
numbersep=5pt,
tabsize=4,
extendedchars=true,
breaklines=true,
keywordstyle=\textbf,
stringstyle=\color{white}\ttfamily,
showspaces=false,
showtabs=false,
xleftmargin=17pt,
framexleftmargin=17pt,
framexrightmargin=5pt,
framexbottommargin=4pt,
showstringspaces=false
}

\begin{document}

\begin{lstlisting}
"Try words inside double quotes"

'Try words inside single quotes'

airportsData <- read.csv("dataset\airports.txt", header = FALSE, sep = ",", quote = "\"")

colnames(airportsData) <- c("openflightCode" , "name", "city", "country", "IATA", "ICAO", "latitude", "longitude", "altitude", "timezone", "DST", "tzdb", "type", "source")

\end{lstlisting}

\end{document}

编译之后的结果里,引号中间的内容完全看不到,就像消失了一样,有没有大佬能帮我看看这是哪里出问题了呀?

备注:内容来源于stack exchange,提问作者xSamx02

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.22 12:29:32