- doesn't go in box
- goes in box
- goes in box
- doesn't go in box
- the numbers don't go in box
I'm using \begin{enumerate} for the list.
- doesn't go in box
- goes in box
- goes in box
- doesn't go in box
- the numbers don't go in box
I'm using \begin{enumerate} for the list.
I took one half of this solution to achieve what you want to have. See the linked solution for more details on how you can optimize that.
\documentclass{article}
\usepackage{xparse}
\usepackage{calc}
\usepackage{tikz}
\usetikzlibrary{calc}
\newcommand{\tikzmark}[1]{\tikz[overlay,remember picture] \node (#1) {};}
\makeatletter
\NewDocumentCommand{\DrawBox}{s O{}}{%
\tikz[overlay,remember picture]{
\IfBooleanTF{#1}{%
\coordinate (RightPoint) at ($(left |- right)+(\linewidth-\labelsep-\labelwidth,0.0)$);
}{%
\coordinate (RightPoint) at (right.east);
}%
\draw[red,#2]
($(left)+(-0.2em,0.9em)$) rectangle
($(RightPoint)+(0.2em,-0.3em)$);}
}
\makeatother
\begin{document}
\begin{enumerate}
\item \tikzmark{left}doesn't go in box
\item goes in box\hspace{1cm}\tikzmark{right}\DrawBox[thick,red]
\item \tikzmark{left}goes in box
\item doesn't go in box\tikzmark{right}\DrawBox[dashed, very thick,blue]
\item the numbers don't go in box
\end{enumerate}
\end{document}
Note: You may need to run LaTeX twice to get the correct positions.