Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Is there any way in latex to create a simple box around one item in a list? I tried both \framebox, and \fbox, none of them worked

\begin{enumerate}[label=\Alph*),ref=\Alph*]
{\color{red}\item null.} 
\item lik vektdifferansen $GT - GK$.
\item lik vektsummen $GT + GK$.
\item lik vekten av $K$.
\end{enumerate}

Works, but

\begin{enumerate}[label=\Alph*),ref=\Alph*]

{\color{red}  \fbox{ \item null.} } 

\item lik vektdifferansen $GT - GK$.
\item lik vektsummen $GT + GK$.
\item lik vekten av $K$.
\end{enumerate}

Does not. So yeah, any way to box a single entry in a list?

share|improve this question
    
Presumably \item\fbox{null.} is not acceptable? –  Seamus Nov 2 '11 at 12:54
add comment

2 Answers

up vote 9 down vote accepted

Here's a way of boxing the text and label. It depends on explicitly calling the label. It might also need some tweaking for spacing.

It relies on Andrew Stacey's super smart \tikzmark trick.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc,shapes}
\newcommand{\tikzmark}[1]{\tikz[overlay,remember picture] \node (#1) {};}
\begin{document}
\begin{itemize}
\item[\tikzmark{bl}\textbullet] Something\tikzmark{br}
\item Something not boxed
\item Also not boxed.
\end{itemize}
\tikz[overlay,remember picture]{\draw[red]
  ($(bl)+(-0.2em,0.9em)$) rectangle
  ($(br)+(0.2em,-0.3em)$);}
\end{document}

boxing items

I am fully aware that this is overkill. But that is a good thing!

share|improve this answer
    
I expect this could be partially automated with a wrapper for \item but I don't have time to experiment right now… –  Seamus Nov 2 '11 at 14:34
add comment

You can locally redefine \labelenumi:

\documentclass{article}
\usepackage{xcolor}

\begin{document}

\begin{enumerate}
  \item First item.
  {\renewcommand\labelenumi{\fbox{\theenumi}}
  \item Second boxed item.}
  \item Third item.
\end{enumerate}

\begin{enumerate}
  \item First item.
  {\renewcommand\labelenumi{\colorbox{red}{\theenumi}}
  \item Second boxed and colored item.}
  \item Third item.
\end{enumerate}

\end{document}

enter image description here

share|improve this answer
    
This only boxes the label though, not the item. –  Roelof Spijker Nov 2 '11 at 12:58
    
@wh1t3 yes. I thought that that was the intention of the OP. –  Gonzalo Medina Nov 2 '11 at 13:04
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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