列表中的字体颜色
Fontcolor in listing
我想为 python 代码编写一个清单。我的问题是 x = SUM('ZM_test'[testcol 0AN])
的零是黑色字体颜色而不是绿色。我的列表样式设置如下所示:
\documentclass[12pt,a4paper]{report}
\usepackage[utf8]{inputenc}
\usepackage[german]{babel}
\usepackage[left=4cm,right=3cm,top=2.5cm,bottom=2.5cm]{geometry}
\usepackage{listings}
\usepackage{color}
\definecolor{keywords}{RGB}{255,0,90}
\definecolor{comments}{RGB}{0,0,113}
\definecolor{red}{RGB}{160,0,0}
\definecolor{green}{RGB}{0,150,0}
\lstset{language=Python,
basicstyle=\ttfamily\footnotesize,
keywordstyle=\color{keywords},
commentstyle=\color{comments},
stringstyle=\color{red},
showstringspaces=false,
identifierstyle=\color{green},
%procnamekeys={def,class}
numbers=left,
xleftmargin=2em,
frame=single,
framexleftmargin=1.5em
}
\begin{document}
\begin{lstlisting}[language=Python, caption=xy, label=xy, numbers =left, frame= lines, gobble = 0]
x = SUM('ZM_test'[testcol 0AN])
y = SUM('ZM_test'[testcol bAN])
\end{lstlisting}
\end{document}
你知道吗,为什么零的字体颜色是“黑色”而不是“绿色”?我想要像 y = SUM('ZM_test'[testcol bAN])
中的“b”一样的零绿色
编辑:那不是 python 代码,但它应该是 python 风格。
最好的祝福
克里斯蒂安
您可以尝试 https://tex.stackexchange.com/a/42895
中的方法
\documentclass[12pt,a4paper]{report}
\usepackage[utf8]{inputenc}
\usepackage[german]{babel}
\usepackage[left=4cm,right=3cm,top=2.5cm,bottom=2.5cm]{geometry}
\usepackage{listings}
\usepackage{xcolor}
\definecolor{keywords}{RGB}{255,0,90}
\definecolor{comments}{RGB}{0,0,113}
\definecolor{red}{RGB}{160,0,0}
\definecolor{green}{RGB}{0,150,0}
\lstset{language=Python,
basicstyle=\ttfamily\footnotesize,
keywordstyle=\color{keywords},
commentstyle=\color{comments},
stringstyle=\color{red},
showstringspaces=false,
identifierstyle=\color{green},
%procnamekeys={def,class}
numbers=left,
xleftmargin=2em,
frame=single,
framexleftmargin=1.5em
}
\lstset{literate=%
*{0}{{{\color{green}0}}}1
{1}{{{\color{green}1}}}1
{2}{{{\color{green}2}}}1
{3}{{{\color{green}3}}}1
{4}{{{\color{green}4}}}1
{5}{{{\color{green}5}}}1
{6}{{{\color{green}6}}}1
{7}{{{\color{green}7}}}1
{8}{{{\color{green}8}}}1
{9}{{{\color{green}9}}}1
}
\begin{document}
\begin{lstlisting}[language=Python, caption=xy, label=xy, numbers =left, frame= lines, gobble = 0]
x = SUM('ZM_test'[testcol 0AN])
y = SUM('ZM_test'[testcol bAN])
\end{lstlisting}
\end{document}
我想为 python 代码编写一个清单。我的问题是 x = SUM('ZM_test'[testcol 0AN])
的零是黑色字体颜色而不是绿色。我的列表样式设置如下所示:
\documentclass[12pt,a4paper]{report}
\usepackage[utf8]{inputenc}
\usepackage[german]{babel}
\usepackage[left=4cm,right=3cm,top=2.5cm,bottom=2.5cm]{geometry}
\usepackage{listings}
\usepackage{color}
\definecolor{keywords}{RGB}{255,0,90}
\definecolor{comments}{RGB}{0,0,113}
\definecolor{red}{RGB}{160,0,0}
\definecolor{green}{RGB}{0,150,0}
\lstset{language=Python,
basicstyle=\ttfamily\footnotesize,
keywordstyle=\color{keywords},
commentstyle=\color{comments},
stringstyle=\color{red},
showstringspaces=false,
identifierstyle=\color{green},
%procnamekeys={def,class}
numbers=left,
xleftmargin=2em,
frame=single,
framexleftmargin=1.5em
}
\begin{document}
\begin{lstlisting}[language=Python, caption=xy, label=xy, numbers =left, frame= lines, gobble = 0]
x = SUM('ZM_test'[testcol 0AN])
y = SUM('ZM_test'[testcol bAN])
\end{lstlisting}
\end{document}
你知道吗,为什么零的字体颜色是“黑色”而不是“绿色”?我想要像 y = SUM('ZM_test'[testcol bAN])
编辑:那不是 python 代码,但它应该是 python 风格。 最好的祝福 克里斯蒂安
您可以尝试 https://tex.stackexchange.com/a/42895
中的方法\documentclass[12pt,a4paper]{report}
\usepackage[utf8]{inputenc}
\usepackage[german]{babel}
\usepackage[left=4cm,right=3cm,top=2.5cm,bottom=2.5cm]{geometry}
\usepackage{listings}
\usepackage{xcolor}
\definecolor{keywords}{RGB}{255,0,90}
\definecolor{comments}{RGB}{0,0,113}
\definecolor{red}{RGB}{160,0,0}
\definecolor{green}{RGB}{0,150,0}
\lstset{language=Python,
basicstyle=\ttfamily\footnotesize,
keywordstyle=\color{keywords},
commentstyle=\color{comments},
stringstyle=\color{red},
showstringspaces=false,
identifierstyle=\color{green},
%procnamekeys={def,class}
numbers=left,
xleftmargin=2em,
frame=single,
framexleftmargin=1.5em
}
\lstset{literate=%
*{0}{{{\color{green}0}}}1
{1}{{{\color{green}1}}}1
{2}{{{\color{green}2}}}1
{3}{{{\color{green}3}}}1
{4}{{{\color{green}4}}}1
{5}{{{\color{green}5}}}1
{6}{{{\color{green}6}}}1
{7}{{{\color{green}7}}}1
{8}{{{\color{green}8}}}1
{9}{{{\color{green}9}}}1
}
\begin{document}
\begin{lstlisting}[language=Python, caption=xy, label=xy, numbers =left, frame= lines, gobble = 0]
x = SUM('ZM_test'[testcol 0AN])
y = SUM('ZM_test'[testcol bAN])
\end{lstlisting}
\end{document}