3

I am using the following code borrowed from here:

\documentclass{article}
    
\begin{document}
   \fbox{\parbox{\textwidth}{The \textit{two-step} model of XMCD:
   \hline
    \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{document}

The horizontal line after the first row created using the \hline is not meeting the vertical lines at the ends. How can this horizontal line be made to meet the vertical lines even at the ends?

3
  • 1
    Your MWE does not compile without errors. AND, the error is associated with the \hline. Replace \hline with \par\noindent\hspace{-\fboxsep}\makebox[\dimexpr\linewidth+2\fboxsep\relax]{\hrulefill} Jun 7 at 20:29
  • note that (as latex will have warned you) \fbox{\parbox{\textwidth} is too wide to fit in the page, you should use \fbox{\parbox{\dimexpr\textwidth-2\fboxsep-2\fboxrule} to allow space for the box. Jun 7 at 20:40
  • @ Steven B. Segletes, when I implement the changes as suggested, the vertical spacing in the first row is after the text is a bit too much. How can the horizontal line be placed right after the text with spacing as one would get in a tabular environment?
    – Aim
    Jun 7 at 20:44
6

There are better ways to accomplish what you are attempting, but the \hline you invoke is for use in tabular environments, not in general text. Perhaps the closest thing, using that approach, would be the following.

As David noted, because an \fbox is padded, you have to subtract off the width of the padding and the lines from the \textwidth, for the size of your \parbox. Then, I used an \hrulefill instead of the improper \hline. However, that also needed to be left shifted by \fboxsep, and augmented in length by 2\fboxsep, so as to fill up the gaps on either side caused by the \fbox.

\documentclass{article}   
\begin{document}
   \fbox{\parbox{\dimexpr\textwidth-2\fboxsep-2\fboxrule}%
      {The \textit{two-step} model of XMCD:
   \\[-8pt]\mbox{}\hspace{-\fboxsep}%
    \makebox[\dimexpr\linewidth+2\fboxsep\relax]{\hrulefill}
    \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{document}

enter image description here

3

I propose two solutions using a simple code, based on the framed package:

\documentclass{article}
\usepackage{enumitem}
\usepackage{framed}
\usepackage[svgnames]{xcolor}
\colorlet{TFFrameColor}{Gainsboro!30!Lavender}
\colorlet{TFTitleColor}{black}

\begin{document}

\noindent
\begin{titled-frame}{The \textit{two-step} model of XMCD:}
      \begin{itemize}[wide=0pt, leftmargin=*]
      \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{titled-frame}

\begin{framed} 
The \textit{two-step} model of XMCD:\\
\hspace*{-1.25\FrameSep} \rule{\dimexpr\textwidth + 2\FrameSep}{0.4pt}
      \begin{itemize}[wide=0pt, leftmargin=*]
      \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} 

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.