LaTex技巧(三):如何为自己定制好看的盒子呢?

\fbox和\itemize在一起该如何放置

例如我用下面错误命令示范:

\fbox{The \textit{two-step} model of XMCD:
\begin{itemize}
\item[In the \textit{first step}, circularly polarized X-rays generate photoelectrons
with a spin and/or orbital momentum from a localized atomic inner shell.]
\item[In the \textit{second step}, the 3d shell serves as the detector of the spin or
orbital momentum of the photoelectron. For maximum effect, the photon spin needs to be
aligned with the magnetization direction.]
\end{itemize}
}

会报错或者出现一些奇怪的格式,并没有得到我们想要的。

解决方案

我们将文字内容先用\parbox 括起来,就行了、

\fbox{\parbox{\textwidth}{The \textit{two-step} model of XMCD:
\begin{itemize}
\item In the \textit{first step}, circularly polarized X-rays generate photoelectrons with a spin and/or orbital momentum from a localized atomic inner shell.
\item In the \textit{second step}, the 3d shell serves as the detector of the spin or orbital momentum of the photoelectron. For maximum effect, the photon spin needs to be aligned with the magnetization direction.
\end{itemize}}}

编译效果如下:
LaTex技巧(三):如何为自己定制好看的盒子呢?_第1张图片
注意不要使用[] ,当然边界应当注意下,可使用这个命令:\dimexpr\linewidth-2\fboxsep-2\fboxrule

框架结构

\documentclass{scrartcl} 
\usepackage{framed} 

\begin{document}

\section{With parbox}

\fbox{\parbox{\textwidth}{The \textit{two-step} model of XMCD:
\begin{itemize}
\item In the \textit{first step}, circularly polarized X-rays generate photoelectrons with a spin and/or orbital momentum from a localized atomic inner shell.
\item In the \textit{second step}, the 3d shell serves as the detector of the spin or orbital momentum of the photoelectron. For maximum effect, the photon spin needs to be aligned with the magnetization direction.
\end{itemize}}}

\section{framed}

\begin{framed}
The \textit{two-step} model of XMCD:
\begin{itemize}
\item In the \textit{first step}, circularly polarized X-rays generate photoelectrons with a spin and/or orbital momentum from a localized atomic inner shell.
\item In the \textit{second step}, the 3d shell serves as the detector of the spin or orbital momentum of the photoelectron. For maximum effect, the photon spin needs to be aligned with the magnetization direction.
\end{itemize}
\end{framed}
\end{document}

编译效果如下:
LaTex技巧(三):如何为自己定制好看的盒子呢?_第2张图片

更加灵活的样式

对于自己的格式的灵活性,我建议多看看tcolorbox,mdframed或者甚至bclogo,从简单的框架一步步编辑自己的箱子。运行 texdoc tcolorbox,texdoc mdframed并mdframed bclogo看到很多选项。下面还有一些例子:

\documentclass{scrartcl} 
\usepackage{microtype} 
\usepackage[framemethod=TikZ]{mdframed} 
\usepackage{tcolorbox} 
\usepackage[tikz]{bclogo}
\usepackage{lipsum} 

\begin{document}

\section{With tcolorbox}

\begin{tcolorbox}[
colframe=blue!25,
colback=blue!10,
coltitle=blue!20!black,  
fonttitle=\bfseries,
adjusted title=The {\em two-step} model of XMCD:]
\begin{itemize}
\item In the \textit{first step}, circularly polarized X-rays generate photoelectrons with a spin and/or orbital momentum from a localized atomic inner shell.
\item In the \textit{second step}, the 3d shell serves as the detector of the spin or orbital momentum of the photoelectron. For maximum effect, the photon spin needs to be aligned with the magnetization direction.
\end{itemize}
\end{tcolorbox}

\section{With mdframed}

\begin{mdframed}[
linecolor=black!40,
outerlinewidth=1pt,
roundcorner=.5em,
innertopmargin=1ex,
innerbottommargin=.5\baselineskip,
innerrightmargin=1em,
innerleftmargin=1em,
backgroundcolor=blue!10,
%userdefinedwidth=1\textwidth,
shadow=true,
shadowsize=6,
shadowcolor=black!20,
frametitle={The \textit{two-step} model of XMCD:},
frametitlebackgroundcolor=cyan!40,
frametitlerulewidth=10pt
]

\begin{itemize}
\item In the \textit{first step}, circularly polarized X-rays generate photoelectrons with a spin and/or orbital momentum from a localized atomic inner shell.
\item In the \textit{second step}, the 3d shell serves as the detector of the spin or orbital momentum of the photoelectron. For maximum effect, the photon spin needs to be aligned with the magnetization direction.
\end{itemize}
\end{mdframed}

\section{With bclogo}

\renewcommand\logowidth{16pt}
\begin{bclogo}[
couleur = blue!10,
marge=20,
cadreTitre = true, 
arrondi = 0.3, 
epBarre=3.5,
logo = \bcnucleaire, 
couleurBarre = red!80!blue!60,
ombre=true,
couleurOmbre = blue!20!black!20,
]
{The \textit{two-step} model of XMCD:}
\bigskip
\begin{itemize}
\item In the \textit{first step}, circularly polarized X-rays generate photoelectrons with a spin and/or orbital momentum from a localized atomic inner shell.
\item In the \textit{second step}, the 3d shell serves as the detector of the spin or orbital momentum of the photoelectron. For maximum effect, the photon spin needs to be aligned with the magnetization direction.
\end{itemize}
\end{bclogo}

\end{document}

LaTex技巧(三):如何为自己定制好看的盒子呢?_第3张图片

参考文献:
【1】texexchange 盒子的定制

你可能感兴趣的:(latex模板,latex入门,latex盒子)