某些单词在列表中不可见
Certain Words invisible in lstlisting
我正在使用 LaTeX 和 lstlisting 来显示一些代码示例,但我现在遇到某些单词消失的问题。
\begin{lstlisting}[caption={Berechnen des F-Scores der Features für die Gangphasen des linken Beines.},label=lst:FScore, language=Python] selector = SelectKBest(f_classif, k=3)
selector.fit(df[["AccX", "AccY", "AccZ", "GyroX", "GyroZ", "GyroY", "MagX", "MagY", "MagZ"]], df["PhaseLeft"])
scores = selector.scores_\end{lstlisting}
给我invisible words。有谁知道为什么?显然 "" 是问题,但 ' ' 导致相同。
最小示例
\documentclass[11pt,a4paper,openright,twoside,ngerman]{article}
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}
\usepackage{listings}
\usepackage{courier}
\usepackage[T1]{fontenc}
\usepackage{xcolor}
\begin{document}
\lstset{
basicstyle=\footnotesize\ttfamily, % Default font
aboveskip=7pt,
float=tbp,
basicstyle=\footnotesize,
numbers=left,
stepnumber=1,
showstringspaces=false,
tabsize=1,
breaklines=true,
breakatwhitespace=false,
captionpos=b,
xleftmargin=17pt,
framexleftmargin=17pt,
framexrightmargin=5pt,
framexbottommargin=4pt,
stringstyle=\color{white}\ttfamily, % Color of strings
showspaces=false,
showtabs=false,
}
\lstloadlanguages{
Python
}
\section{Test}
\begin{lstlisting}[caption={Berechnen des F-Scores der Features für die Gangphasen des linken Beines.},label=lst:FScore, language=Python]
selector = SelectKBest(f_classif, k=3)
selector.fit(df[["AccX", "AccY", "AccZ", "GyroX", "GyroZ", "GyroY", "MagX", "MagY", "MagZ"]], df["PhaseLeft"])
scores = selector.scores_
\end{lstlisting}
\end{document}
您明确告诉您的代码以白色打印字符串。如果您选择任何其他颜色,您会看到它们:
\documentclass[11pt,a4paper,openright,twoside,ngerman]{article}
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}
\usepackage{listings}
\usepackage{courier}
\usepackage[T1]{fontenc}
\usepackage{xcolor}
\begin{document}
\lstset{
basicstyle=\footnotesize\ttfamily, % Default font
aboveskip=7pt,
float=tbp,
basicstyle=\footnotesize,
numbers=left,
stepnumber=1,
showstringspaces=false,
tabsize=1,
breaklines=true,
breakatwhitespace=false,
captionpos=b,
xleftmargin=17pt,
framexleftmargin=17pt,
framexrightmargin=5pt,
framexbottommargin=4pt,
stringstyle=\color{red}\ttfamily, % Color of strings
showspaces=false,
showtabs=false,
}
\lstloadlanguages{
Python
}
\section{Test}
\begin{lstlisting}[caption={Berechnen des F-Scores der Features für die Gangphasen des linken Beines.},label=lst:FScore, language=Python]
selector = SelectKBest(f_classif, k=3)
selector.fit(df[["AccX", "AccY", "AccZ", "GyroX", "GyroZ", "GyroY", "MagX", "MagY", "MagZ"]], df["PhaseLeft"])
scores = selector.scores_
\end{lstlisting}
\end{document}
我正在使用 LaTeX 和 lstlisting 来显示一些代码示例,但我现在遇到某些单词消失的问题。
\begin{lstlisting}[caption={Berechnen des F-Scores der Features für die Gangphasen des linken Beines.},label=lst:FScore, language=Python] selector = SelectKBest(f_classif, k=3)
selector.fit(df[["AccX", "AccY", "AccZ", "GyroX", "GyroZ", "GyroY", "MagX", "MagY", "MagZ"]], df["PhaseLeft"])
scores = selector.scores_\end{lstlisting}
给我invisible words。有谁知道为什么?显然 "" 是问题,但 ' ' 导致相同。
最小示例
\documentclass[11pt,a4paper,openright,twoside,ngerman]{article}
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}
\usepackage{listings}
\usepackage{courier}
\usepackage[T1]{fontenc}
\usepackage{xcolor}
\begin{document}
\lstset{
basicstyle=\footnotesize\ttfamily, % Default font
aboveskip=7pt,
float=tbp,
basicstyle=\footnotesize,
numbers=left,
stepnumber=1,
showstringspaces=false,
tabsize=1,
breaklines=true,
breakatwhitespace=false,
captionpos=b,
xleftmargin=17pt,
framexleftmargin=17pt,
framexrightmargin=5pt,
framexbottommargin=4pt,
stringstyle=\color{white}\ttfamily, % Color of strings
showspaces=false,
showtabs=false,
}
\lstloadlanguages{
Python
}
\section{Test}
\begin{lstlisting}[caption={Berechnen des F-Scores der Features für die Gangphasen des linken Beines.},label=lst:FScore, language=Python]
selector = SelectKBest(f_classif, k=3)
selector.fit(df[["AccX", "AccY", "AccZ", "GyroX", "GyroZ", "GyroY", "MagX", "MagY", "MagZ"]], df["PhaseLeft"])
scores = selector.scores_
\end{lstlisting}
\end{document}
您明确告诉您的代码以白色打印字符串。如果您选择任何其他颜色,您会看到它们:
\documentclass[11pt,a4paper,openright,twoside,ngerman]{article}
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}
\usepackage{listings}
\usepackage{courier}
\usepackage[T1]{fontenc}
\usepackage{xcolor}
\begin{document}
\lstset{
basicstyle=\footnotesize\ttfamily, % Default font
aboveskip=7pt,
float=tbp,
basicstyle=\footnotesize,
numbers=left,
stepnumber=1,
showstringspaces=false,
tabsize=1,
breaklines=true,
breakatwhitespace=false,
captionpos=b,
xleftmargin=17pt,
framexleftmargin=17pt,
framexrightmargin=5pt,
framexbottommargin=4pt,
stringstyle=\color{red}\ttfamily, % Color of strings
showspaces=false,
showtabs=false,
}
\lstloadlanguages{
Python
}
\section{Test}
\begin{lstlisting}[caption={Berechnen des F-Scores der Features für die Gangphasen des linken Beines.},label=lst:FScore, language=Python]
selector = SelectKBest(f_classif, k=3)
selector.fit(df[["AccX", "AccY", "AccZ", "GyroX", "GyroZ", "GyroY", "MagX", "MagY", "MagZ"]], df["PhaseLeft"])
scores = selector.scores_
\end{lstlisting}
\end{document}