exam.cls 中的文本溢出了答案框

exam.cls 中的文本溢出了答案框

我是初学者,想尝试用 latex 写实验报告。我在文档类中使用考试,我从其他地方复制了一个模板,现在我尝试写一行,但结果溢出了框。

看起来像这样

我的代码看起来像

\documentclass[a4-paper]{exam}
\printanswers
\usepackage{color}

\begin{document}
    \begin{questions}
        \question\textbf{Briefly describe the steps to request a loan from which your victim will benefit.}
            \begin{solution}
                We found two ways to benefit the victim.
                \begin{itemize}
                    \item We can manipulate the request of loan using a proxy tool (Burp Suite). We see that in our proxy request looks like 

                    \textcolor{red}{creditacc}=184830489\&\textcolor{red}{debitacc}=184830489{}\&\textcolor{red}{loan}=1234\&\textcolor{red}{period}=1\&\textcolor{red}{submit}=Request
                        \&\textcolor{red}{interest}=\textcolor{blue}{4.2}

                    Now we 
                \end{itemize}
            \end{solution}
    \end{questions}
\end{document}

有解决办法吗?

答案1

一个解决方案就是仅\newline在您希望中断出现时使用。

\documentclass[a4-paper]{exam}
\printanswers
\usepackage{color}

\begin{document}
    \begin{questions}
        \question\textbf{Briefly describe the steps to request a loan from which your victim will benefit.}
            \begin{solution}
                We found two ways to benefit the victim.
                \begin{itemize}
                    \item We can manipulate the request of loan using a proxy tool (Burp Suite). We see that in our proxy request looks like 

                    \textcolor{red}{creditacc}=184830489\&\textcolor{red}{debitacc}=184830489{}\&\textcolor{red}{loan}=1234\&\textcolor{red}{period}=1\&\textcolor{red}{submit}=Request
                        \newline
                        \&\textcolor{red}{interest}=\textcolor{blue}{4.2}

                    Now we 
                \end{itemize}
            \end{solution}
    \end{questions}
\end{document}

在此处输入图片描述

我的第二个建议是定义\&新的命令,这样在每个“&”之前都可以通过插入来中断\-,并且我们还使用sloppyparlatex 抓住这个机会,无论行是否已填充。我在本地定义了这个新命令,但您也可以在序言中定义它,以便它影响所有内容,或者您​​可以为其定义一个新命令并在文档中使用它。

\documentclass[a4-paper]{exam}
\printanswers
\usepackage{color}

\begin{document}
    \begin{questions}
        \question\textbf{Briefly describe the steps to request a loan from which your victim will benefit.}
            \begin{solution}
                We found two ways to benefit the victim.
                \begin{itemize}
                    \item We can manipulate the request of loan using a proxy tool (Burp Suite). We see that in our proxy request looks like 

                \begin{sloppypar}

                \let\oldand\&
                \renewcommand\&{\-\oldand}


                    \textcolor{red}{creditacc}=184830489\&\textcolor{red}{debitacc}=184830489{}\&\textcolor{red}{loan}=1234\&\textcolor{red}{period}=1\&{}\textcolor{red}{submit}=Request\&\textcolor{red}{interest}=\textcolor{blue}{4.2}
                \end{sloppypar}

                    Now we
                \end{itemize}
            \end{solution}
    \end{questions}
\end{document}

在此处输入图片描述

相关内容