21

I'm trying to place some text inside of a box, here's what I'm writing that is not working:

\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}
}

It doesn't build and compile, the best I've gotten is a box around the very first sentence and then some weird formatting issues... TexStudio doesn't like me placing the closing bracket for \fbox anywhere else.

0

3 Answers 3

21

You can enclose your text with \parbox first then \fbox, such that:

\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}}}

produces:enter image description here

In addition, don't enclose text of item with bracket [].

1
  • 4
    You should consider using a width of \dimexpr\linewidth-2\fboxsep-2\fboxrule to avoid the size of the box to extend over the text block boundary.
    – Werner
    Jul 28, 2013 at 1:26
18

Francis already gave an answer with \parbox. Werner gave a comment for boundaries.

I would recommend to use the framed-environment:

\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}

With the framed-environment you get a nicer look:

result of code example

Beside the better result, also the TeX-source looks more Markup-like.

2
  • What do you mean by "markup"?
    – user17338
    Jul 28, 2013 at 21:35
  • You don't describe how it should look like, but describe what you want. If you would make it even more markup-like, you should define a new environment modeldescription. The decision, how modeldescription should look like is defined later.
    – knut
    Jul 29, 2013 at 21:35
12

For their flexibility in the format, I suggest take a look to the packages tcolorbox, mdframed, or even bclogo, to make from simple frames with sharp corners to really fancy boxes. Run texdoc tcolorbox, texdoc mdframed and texdoc bclogoto see a lot of options. Some examples:

MWE

\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}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .