\lstinline の引数内にパイプ文字を使用できますか?

\lstinline の引数内にパイプ文字を使用できますか?

私は Listings パッケージを使用していますが、パイプを開始文字と終了文字として使用するコマンド|でパイプ文字を使用できるかどうかを尋ねたいと思いました。\lstinline

\documentclass[]{article}
\usepackage{listings}
\begin{document}
Here's some text and an if-statement: \lstinline|if(a == 5 || b == 3)|. %Not working as lstinline stops after the first character of the 'or'-sign |
\end{document}

ご協力いただきありがとうございます!

答え1

からlistings ドキュメンテーション(セクション4.2 組版リスト):

\lstinline[<key=value list>]<character><source code><same character>

はのように動作します\verbが、アクティブな言語とスタイルを尊重します。 これらのリストは、オプションの引数で別途要求されない限り、柔軟な列を使用し、フレームや背景色をサポートしません。 \lstinline!var i:integer;!と記述して を取得できます。 コマンドは最初にオプションの引数を探すため、としてvar i:integer;使用する場合は少なくとも空の引数を指定する必要があります。[<character>

したがって、 を使用する場合は、インライン リストを閉じるために<character>を使用する必要があります(実験的な...の使用を除く)。インラインの使用と競合しない文字を選択します。<same character>{}

ここに画像の説明を入力してください

\documentclass{article}
\usepackage{listings}
\lstset{basicstyle=\ttfamily}
\begin{document}
Here's some text and an if-statement: \lstinline!if(a == 5 || b == 3)!.

Or there is \lstinline+if(a != 3 && b !=3 || c != 4)+.
\end{document}

関連情報