如何在不影响排版和可读性的情况下最好地区分文档中的问题和答案?

如何在不影响排版和可读性的情况下最好地区分文档中的问题和答案?

先说明一下:我不认为这个问题完全是主观的,甚至在很大程度上不是主观的,因为它寻求的是如何实现客观的功利目标。请阅读:

我正在解决 QFT 作业LaTeX。它们基本上只是一系列的问题和答案,我很想知道您的意见,如何才能最好地让读者清楚地知道文本是属于问题还是给出了答案。

过去,我把整个问题都用斜体字写出来,比如

\newcommand{\question}[1]{\itshape #1}

但是,我始终不满意,因为它使问题更难阅读,并且整个页面布局看起来相当混乱。有什么建议吗?

编辑:Manuel 要求提供一个可编译的示例,所以您可以看看。我从以下内容中去掉了几乎所有不必要的代码。请注意,b) 的答案很难从问题列表中辨别出来。

在此处输入图片描述

\documentclass[12pt]{article}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage{microtype}

\usepackage[a4paper,margin=25mm]{geometry}

\usepackage{amsmath}
\usepackage{amssymb}
\usepackage[range-units = single]{siunitx}
\sisetup{detect-all,per-mode=fraction}

\usepackage[inline]{enumitem}
\setlist[enumerate]{leftmargin=0ex,label=\alph*)}
\setlist[itemize,1]{leftmargin=*}


\setlength{\parindent}{0ex}


\renewcommand{\vec}[1]{\boldsymbol{#1}}
\newcommand{\der}{\operatorname{d\!}{}}
\newcommand{\spint}[1][x]{\int_{\mathbb{R}^3} \! \der^3#1 \,}
\newcommand{\moint}{\int_{\mathbb{R}^3} \! \frac{\der^3p}{\(\num{2}\pi\)^{\num{3}}} \,}
\newcommand{\vnabla}{\vec{\nabla}}
\renewcommand{\(}{\left(}
\renewcommand{\)}{\right)}
\renewcommand{\[}{\left[}
\renewcommand{\]}{\right]}
\let\phi\varphi



\begin{document}

\section{Canonical commutation relations}

Starting from the mode expansion of the Schrödinger fields
\begin{align}
&\phi\(\vec{x}\) = \moint \frac{\num{1}}{\sqrt{\num{2}\omega_{\vec{p}}}} \(a\(\vec{p}\)e^{i\vec{p}\vec{x}} + a^\dagger\(\vec{p}\)e^{-i\vec{p}\vec{x}}\), \\
\text{and} \quad &\pi\(\vec{x}\) = \moint (-i) \sqrt{\frac{\omega_{\vec{p}}}{\num{2}}} \(a\(\vec{p}\)e^{i\vec{p}\vec{x}} - a^\dagger\(\vec{p}\)e^{-i\vec{p}\vec{x}}\),
\end{align}
we’ll derive the canonical commutation relations for the modes $a\(\vec{p}\)$ and $a^\dagger\(\vec{p}\)$ using the steps below.
\begin{enumerate}
\item Perform a Fourier transformation to deduce the relation between the Fourier modes $\tilde{\phi}\(\vec{p}\)$, $\tilde{\pi}\(\vec{p}\)$, and the modes $a\(\vec{p}\)$ and $a^\dagger\(\vec{p}\)$.
\item Derive the commutation relations
\begin{equation}
\[\tilde{\phi}\(\vec{p}\),\tilde{\pi}\(\vec{q}\)\] = i \(\num{2}\pi\)^{\num{3}} \delta^{\(\num{3}\)}\(\vec{p} + \vec{q}\)
\end{equation}
from the canonical commutation relations for $\phi\(\vec{x}\)$ and $\pi\(\vec{x}\)$.

%%%%%% All text belongs to questions except for this block. %%%%%%
The canonical commutation relations for $\phi\(\vec{x}\)$ and $\pi\(\vec{x}\)$ states that $\[\phi\(\vec{x}\),\pi\(\vec{y}\)\] = i \delta^{\(\num{3}\)}\(\vec{x} - \vec{y}\)$. Therefore
\begin{equation}
\begin{aligned}
\[\tilde{\phi}\(\vec{p}\),\tilde{\pi}\(\vec{q}\)\]
&= \spint\spint[y] e^{-i\vec{p}\vec{x}} e^{-i\vec{p}\vec{y}} \underbrace{\[\phi\(\vec{x}\),\pi\(\vec{y}\)\]}_{i \delta^{\(\num{3}\)}\(\vec{x} - \vec{y}\)} \\
&= i \spint e^{-i\(\vec{p}+\vec{q}\)\vec{x}}
= i \(\num{2}\pi\)^{\num{3}} \delta^{\(\num{3}\)}\(\vec{p} + \vec{q}\)
\end{aligned}
\end{equation}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\item Conclude that
\begin{equation}
\[a\(\vec{p}\),a^\dagger\(\vec{q}\)\] = \(\num{2}\pi\)^{\num{3}} \delta^{\(\num{3}\)}\(\vec{p} - \vec{q}\)
\quad \text{and} \quad
\[a\(\vec{p}\),a\(\vec{q}\)\] = \[a^\dagger\(\vec{p}\),a^\dagger\(\vec{q}\)\] = \num{0}.
\end{equation}
\end{enumerate}

\end{document}

更新:两张图片响应 Peter Grill 的解决方案。

在此处输入图片描述 在此处输入图片描述

答案1

mdframed以下是用于突出显示答案部分的示例:

在此处输入图片描述

参考:

代码:

\documentclass[12pt]{article}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage{microtype}

\usepackage[a4paper,margin=25mm]{geometry}

\usepackage{amsmath}
\usepackage{amssymb}
\usepackage[range-units = single]{siunitx}
\sisetup{detect-all,per-mode=fraction}

\usepackage[inline]{enumitem}
\setlist[enumerate]{leftmargin=0ex,label=\alph*)}
\setlist[itemize,1]{leftmargin=*}


\setlength{\parindent}{0ex}


\renewcommand{\vec}[1]{\boldsymbol{#1}}
\newcommand{\der}{\operatorname{d\!}{}}
\newcommand{\spint}[1][x]{\int_{\mathbb{R}^3} \! \der^3#1 \,}
\newcommand{\moint}{\int_{\mathbb{R}^3} \! \frac{\der^3p}{\(\num{2}\pi\)^{\num{3}}} \,}
\newcommand{\vnabla}{\vec{\nabla}}
\renewcommand{\(}{\left(}
\renewcommand{\)}{\right)}
\renewcommand{\[}{\left[}
\renewcommand{\]}{\right]}
\let\phi\varphi

\usepackage{xcolor}
\usepackage{mdframed}
\newmdenv[%
    leftmargin=-5pt,
    rightmargin=-5pt, 
    innerleftmargin=5pt,
    innerrightmargin=5pt,
    backgroundcolor=brown!10,
]{Answer}%


\begin{document}

\section{Canonical commutation relations}

Starting from the mode expansion of the Schrödinger fields
\begin{align}
&\phi\(\vec{x}\) = \moint \frac{\num{1}}{\sqrt{\num{2}\omega_{\vec{p}}}} \(a\(\vec{p}\)e^{i\vec{p}\vec{x}} + a^\dagger\(\vec{p}\)e^{-i\vec{p}\vec{x}}\), \\
\text{and} \quad &\pi\(\vec{x}\) = \moint (-i) \sqrt{\frac{\omega_{\vec{p}}}{\num{2}}} \(a\(\vec{p}\)e^{i\vec{p}\vec{x}} - a^\dagger\(\vec{p}\)e^{-i\vec{p}\vec{x}}\),
\end{align}
we’ll derive the canonical commutation relations for the modes $a\(\vec{p}\)$ and $a^\dagger\(\vec{p}\)$ using the steps below.
\begin{enumerate}
\item Perform a Fourier transformation to deduce the relation between the Fourier modes $\tilde{\phi}\(\vec{p}\)$, $\tilde{\pi}\(\vec{p}\)$, and the modes $a\(\vec{p}\)$ and $a^\dagger\(\vec{p}\)$.
\item Derive the commutation relations
\begin{equation}
\[\tilde{\phi}\(\vec{p}\),\tilde{\pi}\(\vec{q}\)\] = i \(\num{2}\pi\)^{\num{3}} \delta^{\(\num{3}\)}\(\vec{p} + \vec{q}\)
\end{equation}
from the canonical commutation relations for $\phi\(\vec{x}\)$ and $\pi\(\vec{x}\)$.

\begin{Answer}
%%%%%% All text belongs to questions except for this block. %%%%%%
The canonical commutation relations for $\phi\(\vec{x}\)$ and $\pi\(\vec{x}\)$ states that $\[\phi\(\vec{x}\),\pi\(\vec{y}\)\] = i \delta^{\(\num{3}\)}\(\vec{x} - \vec{y}\)$. Therefore
\begin{equation}
\begin{aligned}
\[\tilde{\phi}\(\vec{p}\),\tilde{\pi}\(\vec{q}\)\]
&= \spint\spint[y] e^{-i\vec{p}\vec{x}} e^{-i\vec{p}\vec{y}} \underbrace{\[\phi\(\vec{x}\),\pi\(\vec{y}\)\]}_{i \delta^{\(\num{3}\)}\(\vec{x} - \vec{y}\)} \\
&= i \spint e^{-i\(\vec{p}+\vec{q}\)\vec{x}}
= i \(\num{2}\pi\)^{\num{3}} \delta^{\(\num{3}\)}\(\vec{p} + \vec{q}\)
\end{aligned}
\end{equation}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\end{Answer}

\item Conclude that
\begin{equation}
\[a\(\vec{p}\),a^\dagger\(\vec{q}\)\] = \(\num{2}\pi\)^{\num{3}} \delta^{\(\num{3}\)}\(\vec{p} - \vec{q}\)
\quad \text{and} \quad
\[a\(\vec{p}\),a\(\vec{q}\)\] = \[a^\dagger\(\vec{p}\),a^\dagger\(\vec{q}\)\] = \num{0}.
\end{equation}
\end{enumerate}
\end{document}

相关内容