0

I'm trying to write:

LCD_write_String_to_Buffer("Esperando      \nconfiguracion...");

but what I get is:

enter image description here

I get like horizontal square brackets. Is there any way to remove all symbols and leave the space empty between "Esperando" and the "\n"?

I'm using listings with this syntax color:

\lstset{language=C++,
            keywordstyle=\color{RedViolet},
            stringstyle=\color{blue},
            commentstyle=\color{ForestGreen},
            morecomment=[l][\color{Orange}]{\#}
}

Thanks in advanced.

marked as duplicate by Uwe Ziegenhagen, Svend Tveskæg, user13907, Werner spacing Aug 5 '15 at 23:55

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 2
    Are you using listings or any other package? Provide a minimal complete document illustrating the problem. – Gonzalo Medina Aug 5 '15 at 22:53
  • 1
    Welcome to TeX.SX! How is this connected to LaTeX? What is LCD_write_String_to_Buffer? – user31729 Aug 5 '15 at 22:53
  • 1
    I don't think this is TeX-related. Rather looks like Arduino... – Uwe Ziegenhagen Aug 5 '15 at 22:53
  • 2
    What you're getting there is a space character. This is the expected behaviour in some cases and environments and when using some packages. It can probably be turned off with an option or declaration. However, for us to know the cause - and the solution - we need a lot more information. TeX is pretty broad, there are lots of packages, lots of different uses for it, lots of variables. This why we always like to have an MWE (meta.tex.stackexchange.com/questions/228/…). – Au101 Aug 5 '15 at 22:57
  • 2
    If you'd provided an MWE, we'd've known you were using listings and we could've got started on your problem straight away. Compiling an MWE may also have allowed you to diagnose and solve the problem yourself. – Au101 Aug 5 '15 at 22:58
2

Use showstringspaces=false; either globally (for all your listings):

\documentclass{article}
\usepackage[dvipsnames]{xcolor}
\usepackage{listings}

\lstset{
  showstringspaces=false,
  language=C++, 
  keywordstyle=\color{RedViolet}, 
  stringstyle=\color{blue}, 
  commentstyle=\color{ForestGreen}, 
  morecomment=[l][\color{Orange}]{\#},
}


\begin{document}

\begin{lstlisting}
LCD_write_String_to_Buffer("Esperando      \nconfiguracion...");
\end{lstlisting}

\end{document}

or locally (for a particular one):

\documentclass{article}
\usepackage[dvipsnames]{xcolor}
\usepackage{listings}

\lstset{
  language=C++, 
  keywordstyle=\color{RedViolet}, 
  stringstyle=\color{blue}, 
  commentstyle=\color{ForestGreen}, 
  morecomment=[l][\color{Orange}]{\#},
}


\begin{document}

\begin{lstlisting}[showstringspaces=false]
LCD_write_String_to_Buffer("Esperando      \nconfiguracion...");
\end{lstlisting}

\end{document}

The result in both cases:

enter image description here

  • that works, but in my case I'm using some syntax color: \lstset{language=C++, keywordstyle=\color{RedViolet}, stringstyle=\color{blue}, commentstyle=\color{ForestGreen}, morecomment=[l][\color{Orange}]{\#} } and in that case it wont work – tulians Aug 5 '15 at 23:04
  • 2
    @tulians And how do you expect me to guess that? Always provide complete minimal documents in your questions. – Gonzalo Medina Aug 5 '15 at 23:05
  • @tulians Please see my updated answer. – Gonzalo Medina Aug 5 '15 at 23:25
  • 4
    @tulians You're new. Of course we can be patient, it takes time to learn how things are done when you first join a community. But I hope now you realise why we insist on MWEs. Not only could you have got your answer sooner, without needing to explain everything after writing your question; but you also sent Gonzalo Medina on a bit of a wild goose chase - causing him to waste a little of his own, spare time. So hopefully, now you know, next time you won't make a similar mistake :) In the meantime, read the tour tex.stackexchange.com/tour and earn a badge :) – Au101 Aug 5 '15 at 23:34
  • 2
    @Au101 Such a nice comment. Thanks for writting it. – Gonzalo Medina Aug 5 '15 at 23:43

Not the answer you're looking for? Browse other questions tagged or ask your own question.