#\lstinputlisting colours not showing up for special letters!
1 messages · Page 1 of 1 (latest)
\Google%just a theme
\lstset{
literate=%
{č}{{\v{c}}}1
{š}{{\v{s}}}1
{ž}{{\v{z}}}1,
language=C
}
\begin{lstlisting}
printf("csz");
printf("čšž");
getchar();
\end{lstlisting}
@tawny tartan does it work for you if you include it from a file
using \lstinputlisting[]{file.c}
I've tried putting the literates inside \lstdefinestyle and \lstset, but nothing worked
\begin{filecontents*}{file.c}
printf("csz");
printf("čšž");
getchar();
\end{filecontents*}
\Google%just a theme
\lstset{
literate=%
{č}{{\v{c}}}1
{š}{{\v{s}}}1
{ž}{{\v{z}}}1,
language=C
}
\lstinputlisting{file.c}
Again, I cannot recreate the problem you are encountering.
then it must be the theme, because I'm using \lstdefinestyle and you're using some other Google theme I do not know how to set
yeah, isn't this the point of the problem?
\begin{filecontents*}{file.c}
printf("csz");
printf("čšž");
getchar();
\end{filecontents*}
\lstset{
literate=%
{č}{{\v{c}}}1
{š}{{\v{s}}}1
{ž}{{\v{z}}}1,
language=C
}
\lstinputlisting{file.c}
(this is the only reason why i used a light-coloured theme named Google)
but anyway the colours/themes aren't the problem in the context of highlighting the strings
\lstdefinestyle{code}{
backgroundcolor = \color{orange},
stringstyle = \color{teal},
basicstyle = \ttfamily,
captionpos = b,
language = C,
}
\lstset{style = code}
let's say this would be example style, which doesn't work
\lstinputlisting[caption = Caption]{Example.c}
``` this is how I'd put it in the document
I thought this was about čšž not being highlighted properly, where everything else was being correctly highlighted?
I'm seriously struggling to recreate the problem.
so this works?
can you try in lualatex, because that's what I'm using
can you send your files so I can see if it would work for me
This is the MWE.
(minus the \Google of course.)
I'll write it again for you
\begin{filecontents*}{file.c}
printf("csz");
printf("čšž");
getchar();
\end{filecontents*}
\lstset{
literate=%
{č}{{\v{c}}}1
{š}{{\v{s}}}1
{ž}{{\v{z}}}1,
language=C,
stringstyle=\color{magenta}
}
\lstinputlisting{file.c}
and this is what you should get.
lstset is in the preamble, right?
well I have \lstset{style = code} in the preamble and the styling works as shown in my problem
do you include any packages? I cannot find any that would be connected to listings
\lstset and \lstinputlisting are provided by listings and to use colours I loaded xcolor
Nothing else
oh I found it, it doesn't load unless \usepackage[most]{tcolorbox} is loaded
otherwise it says ! Undefined control sequence. \lstset
in my main document, I use tcolorbox for some other boxes that's why I didn't include listings
lstset is defined in listings
I presume you needed something like \tcbuselibrary{listings}
how do you see in your files if it's correctly highlighted? with the code you provided, there's no theme and so it's just black and white serif font
stringstyle=\color{magenta} key-value pair should highlight the strings as desired.
In case you don't believe me:
The code in the screenshot is exactly the same as this code, so you should see the same output.
but I don't
I don't know what else I can do at this point, seems to be new details popping up with every exchange
I'm sure a more experienced TeXnician will help you out, good luck!
you use vim?
I tried with texworks and it appears to work now, though it has trouble making the entire document that I have the rest of stuff in
I am familiar with vim
which editor do you use then
VSCode most often, a heavily-modded version of TeXStudio second