讓這段文字看起來不錯

讓這段文字看起來不錯

我在讓這段文字看起來不錯時遇到一些問題: 在此輸入影像描述

這是我現在擁有的 LaTeX 程式碼:

\begin{equation}
    \begin{split}
        alert\ http\ \$EXTERNAL\_NET\ any\ \rightarrow \$HOME\_NET\ any\ 
        (msg:"Hacker\ is\ here!";\ \\ dsize:>100;\  type:"response";\ 
        content:"Bootstrap";\ sid:123;)
    \end{split}
\end{equation}

我將不勝感激所有幫助,試圖讓這看起來更好。我知道我無法在一行中得到它,但它也不必是一個方程,因此不需要 3.1。但也許你有一些想法?我也不喜歡在方程中冒號之前自動添加的空格。

答案1

我喜歡這樣

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\[
\begin{array}{l}
\text{alert http }\$EXTERNAL\_NET\ any\rightarrow \$HOME\_NET\ any\\
(\\
\qquad\begin{array}{l@{\ }cl}
    msg&:&\text{``Hacker is here!''};\\
    dsize&:&>100;\\
    type&:&\text{``response''};\\
    content&:&\text{``Bootstrap''};\\
    sid&:&123;\\
\end{array}\\
)
\end{array}
\]
\end{document}

在此輸入影像描述

筆記:果斷。選擇最佳答案來勾選接受標記。在你上一個問題中,我看到你勾選了所有答案,但你只能接受他們! (但我認為當前接受的答案很好。)

答案2

您應該花時間考慮此類物件的一致格式。

這是一個嘗試。請記住為不同類型的物件定義宏,以便您(或其他人)願意時可以輕鬆更改格式。

\documentclass{article}
\usepackage{amsmath}

\newcommand{\envvar}[1]{\texttt{\$#1}}
\newcommand{\tdesc}[1]{\textup{``#1''}}

\begin{document}

\[
\begin{tabular}{@{}l@{}}
alert http \envvar{EXTERNAL\_NET} any \\
\qquad $\rightarrow$ \envvar{HOME\_NET} any (
  \begin{tabular}[t]{@{}l@{ }c@{ }l@{}}
  msg     &:& \tdesc{Hacker is here!}; \\
  dsize   &:& $>100$; \\
  type    &:& \tdesc{response}; \\
  content &:& \tdesc{Bootstrap}; \\
  sid     &:& $123$; )
\end{tabular}
\end{tabular}
\]

\end{document}

在此輸入影像描述

相關內容