所以我有一些 LaTeX,看起来像
\usepackage{graphicx,bm,times, hyperref, amsmath, listings, xcolor, enumitem}
\lstset{language = C++}
\lstdefinestyle{customcpp}{
backgroundcolor=\color[rgb]{0.09, 0.09, 0.09},
belowcaptionskip=1\baselineskip,
breaklines=true,
frame=single,
xleftmargin=\parindent,
language=C++,
showstringspaces=false,
basicstyle=\footnotesize\ttfamily,
keywordstyle=\color[rgb]{0.36, 0.55, 0.84},
commentstyle=\itshape\color[rgb]{0.34, 0.65, 0.29},
identifierstyle=\color[rgb]{0.9, 0.9, 0.9},
stringstyle=\color[rgb]{0, 0.5, 0},
literate=*{\{}{{\color[rgb]{0.9, 0.9, 0.9}{\{}}}{1}
{\}}{{\color[rgb]{0.9, 0.9, 0.9}{\}}}}{1},
}
\lstset{escapechar=@,style=customcpp}
后来:
\begin{lstlisting}
struct Transform
{
sf::Vector2f position;
float rotation;
};
\end{lstlisting}
这样做的结果是,在列出之前,正常文本看起来很好,列表本身看起来很棒,但是在列出之后,正常文本保留了列表内标识符的颜色,所以基本上你看不到文本(白页上的灰白色文本)。
请帮忙。这不是紧急问题,但我希望尽快摆脱这个烦恼。
答案1
在literate*
literate=*{\{}{{\color[rgb]{0.9,0.9,0.9}{\{}}}{1}{\}}{{\color[rgb]{0.9, 0.9, 0.9}{\}}}}{1}
似乎解决了这个问题:
代码:
\documentclass{article}
\usepackage{graphicx,bm,times, hyperref, amsmath, listings, xcolor, enumitem}
\lstset{language = C++}
\lstdefinestyle{customcpp}{
backgroundcolor=\color[rgb]{0.09, 0.09, 0.09},
belowcaptionskip=1\baselineskip,
breaklines=true,
frame=single,
xleftmargin=\parindent,
language=C++,
showstringspaces=false,
basicstyle=\footnotesize\ttfamily,
keywordstyle=\color[rgb]{0.36, 0.55, 0.84},
commentstyle=\itshape\color[rgb]{0.34, 0.65, 0.29},
identifierstyle=\color[rgb]{0.9, 0.9, 0.9},
stringstyle=\color[rgb]{0, 0.5, 0},
%literate=*{\{}{{\color[rgb]{0.9, 0.9, 0.9}{\{}}}{1}{\}}{{\color[rgb]{0.9, 0.9, 0.9}{\}}}}{1},
literate=*{\{}{{{\color[rgb]{0.9, 0.9, 0.9}}}}1{\}}{{{\color[rgb]{0.9, 0.9, 0.9}}}}1,
}
\lstset{escapechar=@,style=customcpp}
\begin{document}
Some text before
\begin{lstlisting}
struct Transform
{
sf::Vector2f position;
float rotation;
};
\end{lstlisting}
Some text after.
\end{document}