如何让 LATEX 上的特定行正确显示以便复制和粘贴?

如何让 LATEX 上的特定行正确显示以便复制和粘贴?

如何才能在我的 Latex 文档中正确显示此行?我试图输入代码语句,但当我尝试从 LATEX 复制并发布到终端时,它不会粘贴整行。

其代码如下:

\documentclass{article}
\usepackage[a4paper, margin=1in]{geometry} % Adjust margins if needed
\usepackage{listings} % For code snippets
\usepackage{xcolor} % For syntax highlighting
\usepackage{hyperref}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\lstset{
    language=python,
    backgroundcolor=\color{white},
    keywordstyle=\color{blue},
    stringstyle=\color{red},
    commentstyle=\color{green!60!black},
    basicstyle=\ttfamily\small,
    breaklines=true,
    showstringspaces=false,
    numbers=left,
    numberstyle=\tiny\color{gray},
    frame=single,
    captionpos=b,
    escapeinside={(*@}{@*)}, % If you need to include LaTeX code within listings
}

\begin{document}
\maketitle

\section{OpenCV}
This section will cover the basic steps for opencv installation. Please follow the necessary steps:
\begin{lstlisting}[caption={OpenCV 4.5.3}]
(*@sudo apt-get install libavcodec-dev libavformat-dev libavutil-dev libswscale-dev@*)
(*@sudo apt-get install libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev@*)
(*@sudo apt install libgtk2.0-dev pkg-config@*)
(*@sudo apt-get update@*)
(*@sudo apt-get install cmake@*)
# This line does not show properly:
(*@sudo cmake -D WITH\_GSTREAMER=ON -D OPENCV\_GENERATE\_PKGCONFIG=ON -D WITH\_FFMPEG=ON -D WITH\_GTK=ON  /media/nvidia/ssd120G/opencv-4.5.3@*)
\end{lstlisting}

\end{document}

我绝不是高级 Latex 用户。感谢您的帮助。

LATEX_SS

相关内容