我想要打印此文本:
make -j 5 KDEB_PKGVERSION=1.yourcustomname deb-pkg
但我觉得由于下划线,LaTeX 会产生错误缺少$插入而且它也不能打印。
其次,在 \fbox{} 中,我想在下一行打印两个文本(即每行一个文本),因此我使用了 \ 甚至 \par,但它似乎不起作用,而且我想对齐(或)。
\fbox{\texttt{uname -a}\\(or) \texttt{cat /proc/version}}
这是我的完整源代码:
\documentclass[12pt]{article}
\author{Subham Soni S.}
\date{\today}
\title{Compiling and Installing a Kernel 3.13.3 On Ubuntu, Debian and its Derivatives}
\begin{document}
\maketitle
To replace the existing \textsl{kernel} with a new one, do the following:
\begin{enumerate}
\item Create a folder named \emph{kernel} in the home directory.
\item Download the latest kernel to the folder from \texttt{www.kernel.org}.
\item Extract the file.
\item In the terminal, type the following command to \textbf{install the neccesary tools to compile the kernel}:
\begin{center}
\fbox{\texttt{sudo apt-get install gcc libncurses5-dev dpkg-dev}}
\end{center}
\item Enter the directory of the extracted kernel source
\begin{center}
\fbox{\texttt{cd kernel} \par \texttt{cd linux-3.13.3}}
\end{center}
\item Configure the kernel
\begin{center}
\fbox{\texttt{make menuconfig}}
\end{center}
In this menu you can customize your kernel
\item Save and exit
\item Compile the kernel
\begin{center}
\fbox{\texttt{make -j 5 KDEB_PKGVERSION=1.yourcustomname deb-pkg}}
\end{center}
\emph{This process might take a while...}
\item Install the kernel
\begin{center}
\fbox{\texttt{sudo dpkg -i ../linux*.deb}}
\end{center}
\item Reboot
\begin{center}
\fbox{\texttt{sudo reboot}}
\end{center}
\item Run the following commands to check the kernel version
\begin{center}
\fbox{\texttt{uname -a}\\(or) \texttt{cat /proc/version}}
\end{center}
\item You can easily uninstall the kernel with the command:
\begin{center}
\fbox{\texttt{sudo apt-get purge linux-image-3.13.3 linux-image-3.13.3-dbg}}
\end{center}
\end{enumerate}
\end{document}
答案1
让我们变得丰富多彩tcolorbox
:
\documentclass{article}
\usepackage{listings}
\lstdefinestyle{mystyle}{%
basicstyle=\small\ttfamily,
breaklines=true,
columns=fullflexible,
}%
\usepackage{tcolorbox}
\tcbuselibrary{most}
\newtcblisting{session}{%
width=\linewidth,
arc=3pt,
top=-2mm,
bottom=-2mm,
left=0mm,
right=0mm,
boxsep=1mm,
boxrule=1pt,
colback=blue!20!green!20!white,
listing only,
listing options={style=mystyle},
breakable,
}%
\begin{document}
\author{Subham Soni S.}
\date{\today}
\title{Compiling and Installing a Kernel 3.13.3 On Ubuntu, Debian and its Derivatives}
\maketitle
To replace the existing \textsl{kernel} with a new one, do the following:
\begin{enumerate}
\item Create a folder named \emph{kernel} in the home directory.
\item Download the latest kernel to the folder from \texttt{www.kernel.org}.
\item Extract the file.
\item In the terminal, type the following command to \textbf{install the necessary
tools to compile the kernel}:
\begin{session}
sudo apt-get install gcc libncurses5-dev dpkg-dev
\end{session}
\item Enter the directory of the extracted kernel source
\begin{session}
cd kernel
cd linux-3.13.3
\end{session}
\item Configure the kernel
\begin{session}
make menuconfig
\end{session}
In this menu you can customize your kernel
\item Save and exit
\item Compile the kernel
\begin{session}
make -j 5 KDEB_PKGVERSION=1.yourcustomname deb-pkg
\end{session}
\emph{This process might take a while \dots}
\item Install the kernel
\begin{session}
sudo dpkg -i ../linux*.deb
\end{session}
\item Reboot
\begin{session}
sudo reboot
\end{session}
\item Run the following commands to check the kernel version
\begin{session}
uname -a
cat /proc/version
\end{session}
\item You can easily uninstall the kernel with the command:
\begin{session}
sudo apt-get purge linux-image-3.13.3 linux-image-3.13.3-dbg
\end{session}
\end{enumerate}
\end{document}
答案2
问题出在第 28 行,字KDEB_PKGVERSION
。如果你写入KDEB\_PKGVERSION
文件,则有效。
\documentclass[12pt]{article}
\author{Subham Soni S.}
\date{\today}
\title{Compiling and Installing a Kernel 3.13.3 On Ubuntu, Debian and its Derivatives}
\begin{document}
\maketitle
To replace the existing \textsl{kernel} with a new one, do the following:
\begin{enumerate}
\item Create a folder named \emph{kernel} in the home directory.
\item Download the latest kernel to the folder from \texttt{www.kernel.org}.
\item Extract the file.
\item In the terminal, type the following command to \textbf{install the neccesary tools to compile the kernel}:
\begin{center}
\fbox{\texttt{sudo apt-get install gcc libncurses5-dev dpkg-dev}}
\end{center}
\item Enter the directory of the extracted kernel source
\begin{center}
\fbox{\texttt{cd kernel} \par \texttt{cd linux-3.13.3}}
\end{center}
\item Configure the kernel
\begin{center}
\fbox{\texttt{make menuconfig}}
\end{center}
In this menu you can customize your kernel
\item Save and exit
\item Compile the kernel
\begin{center}
\fbox{\texttt{make -j 5 KDEB\_PKGVERSION=1.yourcustomname deb-pkg}}
\end{center}
\emph{This process might take a while...}
\item Install the kernel
\begin{center}
\fbox{\texttt{sudo dpkg -i ../linux*.deb}}
\end{center}
\item Reboot
\begin{center}
\fbox{\texttt{sudo reboot}}
\end{center}
\item Run the following commands to check the kernel version
\begin{center}
\fbox{\texttt{uname -a}}\par
or \fbox{\texttt{cat /proc/version}}
\end{center}
\item You can easily uninstall the kernel with the command:
\begin{center}
\fbox{\texttt{sudo apt-get purge linux-image-3.13.3 linux-image-3.13.3-dbg}}
\end{center}
\end{enumerate}
\end{document}
编辑:
使用命令
\fbox{\texttt{uname -a}}\par
or \fbox{\texttt{cat /proc/version}}
两个框里有两行
答案3
您可以尝试使用fancyvrb
更友好的输入:
\documentclass{article}
\usepackage{fancyvrb}
\DefineVerbatimEnvironment{session}{Verbatim}{frame=single,fontsize=\small}
\begin{document}
\author{Subham Soni S.}
\date{\today}
\title{Compiling and Installing a Kernel 3.13.3 On Ubuntu, Debian and its Derivatives}
\maketitle
To replace the existing \textsl{kernel} with a new one, do the following:
\begin{enumerate}
\item Create a folder named \emph{kernel} in the home directory.
\item Download the latest kernel to the folder from \texttt{www.kernel.org}.
\item Extract the file.
\item In the terminal, type the following command to \textbf{install the necessary
tools to compile the kernel}:
\begin{session}
sudo apt-get install gcc libncurses5-dev dpkg-dev
\end{session}
\item Enter the directory of the extracted kernel source
\begin{session}
cd kernel
cd linux-3.13.3
\end{session}
\item Configure the kernel
\begin{session}
make menuconfig
\end{session}
In this menu you can customize your kernel
\item Save and exit
\item Compile the kernel
\begin{session}
make -j 5 KDEB_PKGVERSION=1.yourcustomname deb-pkg
\end{session}
\emph{This process might take a while \dots}
\item Install the kernel
\begin{session}
sudo dpkg -i ../linux*.deb
\end{session}
\item Reboot
\begin{session}
sudo reboot
\end{session}
\item Run the following commands to check the kernel version
\begin{session}
uname -a
cat /proc/version
\end{session}
\item You can easily uninstall the kernel with the command:
\begin{session}
sudo apt-get purge linux-image-3.13.3 linux-image-3.13.3-dbg
\end{session}
\end{enumerate}
\end{document}
部分图片如下: