3
\item The sum $3-\dfrac{3}{10}+\dfrac{3}{100}-\dfrac{3}{1000} 
      + \cdots + \dfrac{(-1)^k3}{10^k} + \cdots$ is closest to:
\begin{enumerate}
\item[(a)] $\dfrac{2}{e}$
\item[(b)] $2$
\item[(c)] $e$
\item[(d)] $e^2$
\end{enumerate}
3
  • 3
    There is much too little information here to allow anyone to guess at what you want. Even a scanned image of a hand-drawn example would be helpful. – barbara beeton Feb 15 '20 at 22:49
  • 2
    Welcome to tex.se! At the moment it's hard to understand what your question is. Could you please add a minimal working example and explain what you're looking for? You could for example add an illustration of your desired end result. You can also look for similar questions in the past, for example this one or this or this. – TivV Feb 15 '20 at 22:55
  • Welcome to TeX-SE. Please, inform a little bit more clear what you want, preferably with a MWE. – FHZ Feb 15 '20 at 23:04
6

Judging by the code snippet you posted, your document employs the amsmath package. This package provides a macro called \framebox, which (a) should be used in math mode and (b) places a rectangular frame around its argument. I'm assuming that this is what you want to achieve when you wrote that you wish to "put a box around one item" in an enumerate environment.

Two other methods for highlighting objects with color are provided by the xcolor package: \colorbox{<background color>}{<object>} and \fcolorbox{<frame color>}{<background color>}{<object>}. These macros may be used in either text or math mode.

There are still other methods for highlighting or placing box frames around objects. The earlier comment by @TivV points to several postings (and associated answers) that present such methods.

The following code (a) makes your code more LaTeX-idiomatic (e.g., by using \dots and \dotsb in lieu of \cdots) and (b) illustrates the use of \framebox, \colorbox, and \fcolorbox.

enter image description here

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{amsmath} % for "\framebox" macro
\usepackage{xcolor}  % for "\colorbox" and "\fcolorbox" macros
\usepackage{enumitem}
\begin{document}
\begin{itemize}
\item The sum $\displaystyle 3-\frac{3}{10}+\frac{3}{100}
      - \frac{3}{1000} + \dots + \frac{(-1)^k 3}{10^k} 
      + \dotsb$ is closest to:
\begin{enumerate}[label=(\alph*)]
\item $\dfrac{2}{e}$
\item $\framebox{e}$
\item \colorbox{yellow}{$e^2$}
\item $\fcolorbox{orange}{green}{2}$
\end{enumerate}
\end{itemize}
\end{document}
2
  • 1
    Thanks this helped a lot! – Qais Karaki Feb 17 '20 at 22:31
  • Too bad colorbox does not wrap text and puts everything on one line instead. – José Tomás Tocino Jun 27 at 13:54
1

Hi Qais Karaki and Welcome to TeX-SE.

I'm guessing your want to highlight the content after the \itemthan the item itself.

If you want to highlight the number or mark in \item, please check TivV comment.

There some options to put a box around the content after \item, which are indeed just a variation to putting a box around any text.

A MWE follows

\documentclass{article}
\usepackage{lipsum}
\usepackage{tcolorbox}
\usepackage{amsmath}
\begin{document}
\begin{enumerate}
    \item
            \begin{tcolorbox}[width=145mm, halign=center, colframe=black, colback=white, boxsep=0mm, arc=3mm]
                \parbox{135mm}{\lipsum[1]}
            \end{tcolorbox}
    \item
        \begin{tcolorbox}[width=145mm, halign=center, colframe=black, colback=yellow!80!black, boxsep=0mm, arc=3mm]
            \parbox{135mm}{\lipsum[2]}
        \end{tcolorbox}
    \item 
    \framebox[135mm][c]{%
        Not to long text
    }
    \item 
    \framebox{\parbox[c]{135mm}{\lipsum[3]}}
    \item 
        \begin{tcolorbox}[width=145mm, halign=center, colframe=blue, colback=red!80!white, boxsep=0mm, arc=0mm]
            \parbox{135mm}{ %
                \begin{equation}
                    \dfrac{y}{x}
                \end{equation}
            }
        \end{tcolorbox}
\end{enumerate}
\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.