![\lstinline の引数内にパイプ文字を使用できますか?](https://rvso.com/image/305771/%5Clstinline%20%E3%81%AE%E5%BC%95%E6%95%B0%E5%86%85%E3%81%AB%E3%83%91%E3%82%A4%E3%83%97%E6%96%87%E5%AD%97%E3%82%92%E4%BD%BF%E7%94%A8%E3%81%A7%E3%81%8D%E3%81%BE%E3%81%99%E3%81%8B%3F.png)
私は 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}