0

Could be a very beginner question, but still. Considering the following:

\usepackage{framed}
\usepackage{tikz}
\usepackage{listings}
...
\newcommand{\some}{\textcolor{red}{\lstinline{some}}}
\newcommand{\other}{\textcolor{blue}{\lstinline{other}}}
...
\begin{document}
....
\begin{framed}
  \some \other
\end{framed}
....
\end{document}

Which goes into this:enter image description here

Why is there no white space between some and other, when there is a blank space there in the source? How would it be possible to make it consider the blank space in the output?

  • 1
    Because TeX gobbles white space after commands. Use \some\ \other, for example to insert an explicit space character – user31729 Mar 22 '18 at 9:26
  • 1
    You could use the xspace package as well. And well be punished by some certain Italian Professor for using it. I will be punished for suggesting it ;-) – user31729 Mar 22 '18 at 9:33
  • Thanks! What about passing some math as argument to a new command? Considering this \newcommand{\evenmore}[1]{\textcolor{blue}{\lstinline{#1}}} with \evenmore{$\sim$}? – Mihai Mar 22 '18 at 9:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.