0

I use this latex code to define icode commadn with which I can write inline codes:

\definecolor{lightgray}{gray}{0.9}
\lstset
{     
     frame=shadowbox,
     rulecolor=\color{white!80!black},
     rulesepcolor=\color{white!80!black},
     basicstyle=\linespread{0.7}\lstcode,
     showtabs=false,     
     showspaces=false,
     showstringspaces=false,     
     breaklines=true,
     captionpos=b,
     numbers=left, 
     numberstyle=\tiny,     
     breakatwhitespace=true,
     escapeinside={(*@}{@*)},
     commentstyle=\color{white!65!black},
     morekeywords={object, set, prop, suppose, with, in, replace, define, add, new, true, false, check, all, some, select, if, pick},
%    keywordstyle=\color{bluekeywords},
     keywordstyle=\bfseries,
}    
\newcommand{\icode}[1]{\colorbox{lightgray}{\lstinline$#1$}}

But the inline code don't break at the end of a line:

enter image description here

The problem is with \colorbox which doesn't break. But I don't know how to fix it. How can I fix the \icode command so that the codes break at the end of a line?

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.