使用清單格式化 bash

使用清單格式化 bash

我用 LaTeX 編寫了有關 Linux Bash 和 Linux Bash 的文檔。外殼腳本。我遇到了一些問題:

  • 如何在行首開始格式化?
  • 如何在兩個符號之間進行格式化,但前提是兩個符號位於同一行(例如:<>)?
  • 如何將減號格式化為空格或者行尾(不是到下一行)?

這是一張照片:

在此輸入影像描述

以及最小工作範例中的程式碼:

\documentclass{scrbook}
\usepackage[T1]{fontenc}
\usepackage{csquotes}
\usepackage{listings}
\usepackage[dvipsnames]{xcolor}

\lstset{ %
    basicstyle=\ttfamily\footnotesize,
    commentstyle=\color{ForestGreen},
    frame=single,
    keywordstyle=\color{RoyalBlue},
    language=Bash,
    showstringspaces=false,
    %morekeywords={blue},
    morestring=[s][\color{Gray}]{<}{>},
    morestring=[s][\color{OrangeRed}]{\ -}{\ },
    morestring=[s][\color{OrangeRed}]{*}{\ },
    morestring=[s][\color{OrangeRed}]{|}{\ },
    morestring=[s][\color{OrangeRed}]{\&}{\ },
}

\begin{document}

Every time:
\begin{enumerate}
    \item the first string in a line: blue
    \item after a minus \enquote{-} (including itself), which followed a space, the string gets: red
    \item special signs \enquote{* | \&}: red
    \item after a hash \enquote{\#} (including itself): the complete line green
    \item between less/greater than \enquote{<>} (including itself): gray
    \item if a string starts with a slash \enquote{/}: this string black
    \item the rest: black
\end{enumerate}

\begin{lstlisting}
blue -red text
blue -red text  # green ...
blue-blue <gray>
blue * black    # green ...
blue -red <gray>
# green ...
/black/black/ blue -red 
blue -red /black/black/
blue -red black-black
blue black > black
blue black < black
blue -red && black -red <gray> || black -red
/black/black/ blue
\end{lstlisting}

\end{document}

相關內容