> For the complete documentation index, see [llms.txt](https://austinsuyoyo.gitbook.io/latex-tutorial/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://austinsuyoyo.gitbook.io/latex-tutorial/package/listings.md).

# listings- Highlight程式碼

```
\documentclass{report}
\usepackage{listings}
\usepackage{xcolor}
\definecolor{Blue}{rgb}{0,0,1}
\definecolor{Green}{rgb}{0,0.5,0}
\definecolor{Red}{rgb}{0.64,0.08,0.08}
\lstset{
    language=C++,
    captionpos=b,                       % 讓Caption在Bottom的位置
    numbers=left,                       % 程式碼行號
    frame=lines,
    showstringspaces=false,             % "不"標註空格
    escapeinside={(*@}{@*)},            % 脫逃字元
    commentstyle=\color{Green},         % Comment顏色
    keywordstyle=\color{Blue},          % Keyword顏色
    stringstyle=\color{Red},            % String顏色
    basicstyle=\ttfamily\small,         % 字型
}


\begin{document}

\begin{lstlisting}[language=C++, caption={This is caption}]
#include <iostream>
int main()
{
    // Print Hello (*@Test escapeinside@*)
    std::cout << "Hello, world!" << std::endl;
    return 0;
}
\end{lstlisting}


\end{document}
```

![](https://1278227785-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LC9uZM7RrYvbBnp3tOx%2F-LDu4wRvUEMw3gWrnF-l%2F-LDu5Km437tqsAYou92z%2Fimage.png?alt=media\&token=c2ba47ad-effa-45fe-b4a0-d5d53050e41b)
