3

it has been quite a while that I have this problem and I have searched everywhere online and couldn't find a solution.

The problem is latex syntax highlighting doesn't work after this line:

\newcommand{\psins}[1]{\colorbox[rgb]{0.8,0.8,1}{\lstinline[basicstyle=\ttfamily\footnotesize\color{black}]|#1|}}

Everything (almost) after this line is written in the same color. I am using Texmaker on Linux Mint 17. I even compiled texmaker to have the most recent version (4.5) and hoping that it would fix, but no avail. Also, I have read about the bug here https://bugs.kde.org/show_bug.cgi?id=322154 and looked at my latex.xml (which is located at /usr/share/kde4/apps/katepart/syntax) and saw that it's the same as the corrected version in this bug report.

It's still not much of a big problem since I am using \include and doing my writing on different files, but still I was wondering and very curious about what causes this problem.

Thanks


complete tex file to reproduce the bug:

(by the way, that problem didn't occur on this question's code block)

\documentclass[10pt, a4paper]{report}
\usepackage{fullpage}
\usepackage{titlesec}
\usepackage[dvipsnames]{xcolor}     % for bg and fg colors
\usepackage{soul}       
\setul{1pt}{}                       % to underline by \ul{}
\setlength\parindent{0pt}

\definecolor{mygray}{rgb}{0.85,0.85,0.85}
\definecolor{techy}{rgb}{0.65,0.85,0.65}
\renewcommand*{\ttdefault}{pcr}

\usepackage{listings}
\lstset{breaklines=true,frame=single}
\lstdefinestyle{DOS}
{
     backgroundcolor=\color[rgb]{0.34,0,0.34},
     basicstyle=\footnotesize\ttfamily\color{white},
     commentstyle=\color{green}
}

\lstdefinelanguage{pshell}
{
     morecomment=[l]{\#}
}


\newcommand{\psins}[1]{\colorbox[rgb]{0.8,0.8,1}
{\lstinline[basicstyle=\ttfamily\footnotesize\color{black}]|#1|}}

\newcommand{\nottez}[2]{
\begin{center}
   \colorbox{mygray}{ 
   \begin{minipage}{0.9\textwidth}
   {\large \textbf{#1}} \vspace*{3pt} \par #2
   \end{minipage}}
\end{center}}

\newcommand{\technet}[2]{
\begin{center}
   \colorbox{techy}{ 
   \begin{minipage}{0.9\textwidth}
   {\large \color{Sepia}\textbf{#1}} \vspace*{3pt} \par #2
   \end{minipage}}
\end{center}}

% -------------------------------------------------------------------------
\titleformat{\chapter}[display]{\normalfont\Large\bfseries}{\chaptertitlename\ \thechapter}{-4pt}{\setul{2pt}{}\LARGE\ul}
\titlespacing*{\chapter}{0pt}{3mm}{9mm}

% -------------------------------------------------------------------------


\begin{document}

%\include{mstrch3}
now everything after lstinline is in the same color.

\end{document}
14
  • 1
    it would be easier to answer your question if you provides a complete small document showing the problem but in general verbatim-like commands such as listings can not be used in the argument of another command 9or only with severe restrictions. Commented Jan 27, 2016 at 20:12
  • good to know that such commands are not friendly as arguments of another commands. If I know that this is not fixable or too complex to fix, I would look for other methods to highlight text in the typesetted document. But I think that it's the similar to the bug report (on the link in the question) therefore thinking that it could be fixed, just that I am not skilled enough to do it myself.
    – Sam Gold
    Commented Jan 27, 2016 at 21:03
  • It is fixable (see the listings documentation) but you need to give an example, the code you have posted doesn't use lstinline at all so is no use at all in debugging your problem. Surely you can copy a small example from the document where it fails and make this fragment fail, it is hard to debug unseen code. Commented Jan 27, 2016 at 21:14
  • I tried \psins{abc < *.* dir } now everything after lstinline is in the same color. but the now everything... was in black so you really need to provide an example. Commented Jan 27, 2016 at 21:18
  • 2
    Sorry that apparently I haven't explained the problem correctly. What I wanted to say is that everything works perfect after typeset -- that's the compiling runs without problem, and I get my pdf file with everything typeset and highlighted correctly. The problem is however in exactly above code block. That is, if you copy paste it into any latex editor, you'd notice that after line starting with \newcommand{\psins} syntax color doesn't change. Compiling is not necessary to reproduce the bug -- just copy paste the above code into any latex editor which has syntax highlight feature
    – Sam Gold
    Commented Jan 27, 2016 at 21:38

1 Answer 1

0

I had the same problem, I used the following workaround to avoid it

\newcommand{\lstinlineProxy}[1]{\lstinline{#1}}

Then in my code, I use lstinlineProxy instead of lstinline. That way, texstudio is not aware of the usage of lstinline.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .