格式更改

格式更改

我想要一些文字显示如下

在此处输入图片描述

我没有得到准确的输出。我写的代码如下(请原谅我对 Latex 的了解不足)

\hspace{2mm}  A simple paragraph of Verilog code is below in verbatim.\\
\begin{flushleft}

Always@(posedge LRCK)

\end{flushleft}

\hspace{5mm} Begin\\

\hspace{6mm} Counter=Counter+1\\

\hspace{6mm} If (Counter == 40)\\

\hspace{5mm}Begin\\

\hspace{6mm} Counter = 0\\

\hspace{5mm} $Phase\_control\_word = Phase\_Control\_word + 1 $

答案1

listings下面是使用支持语言的包的示例Verilog

\documentclass{article}

\usepackage{listings}

\begin{document}

\begin{lstlisting}[language={Verilog},tabsize=12,caption={A simple paragraph of Verilog code is below in verbatim}]
  Always@(posedge LRCK)
  Begin
      Counter=Counter+1
      If ( Counter == 40)
         Begin
         Counter = 0
         Phase_control_word = Phase_Control_word + 1
\end{lstlisting}

\end{document}

在此处输入图片描述

另一个示例tcolorbox及其列表功能:

\documentclass{article}

\usepackage[most]{tcolorbox}

\begin{document}

\begin{tcblisting}{listing options={language={Verilog},tabsize=12}, title={A simple paragraph of Verilog code is below in verbatim},listing only,colbacktitle=yellow, coltitle=black}
  Always@(posedge LRCK)
  Begin
      Counter=Counter+1
      If ( Counter == 40)
         Begin
         Counter = 0
         Phase_control_word = Phase_Control_word + 1
\end{tcblisting}

\end{document}

在此处输入图片描述

相关内容