TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I create two commands for a question with an underlined text in it or box with text in it in a sentence.

This is a sample:

enter image description here

Using the commands for underline and box I can now write it this way:

\question What is the synonym of \underline{Fun}?
\question What is the antonym of \boxed{Old}?
share|improve this question
Every LaTeX guide explains \underline and \fbox – egreg Nov 29 '12 at 16:24
Where’s the actual problem? Do you want a \question macro (Where does that even come from?) do underline/box its full content? If not, is \question related to the actual question? \underline and \boxed are math mode macros (the latter provided by amsmath). Have some ideas: \documentclass{article}\usepackage[normalem]{ulem}\usepackage{amsmath}\begin{do‌​cument}\uline{Fun} \fbox{Old} $\underline{\text{Fun}}$ $\boxed{\text{Fun}}$\end{document} – Qrrbrbirlbel Nov 29 '12 at 17:46
@Qrrbrbirlbel: \question command is given when you use \documentclass{exam} or \question is a macro in exam document class. This macro when used will give the text a numbering order.See in the image example above. What I want to have is a command wherein when used this could automatically underline the text in the argument. Or automatically output the text inside the box. – Kayla Nov 30 '12 at 11:30

All that you need are already supplied by egreg in his comment. Fact: You don't need to define these commands anymore.

You also mentioned the \boxed command. Incidentally, you don't have to define this too. This is already provided by the amsmath package. This works only inside math environments, though.

A demonstration.



\question What is the synonym of \underline{Fun}?
\question What is the antonym of \fbox{old}?
\question Can I use both \verb+\fbox{<>}+ and \verb+\boxed{<>}+ to box words? Perhaps $\boxed{4}$ or \fbox{$4$}?

The output

enter image description here

You can look up most of these commands and many things else by reading The Not So Short Introduction to LaTeX2e or other LaTeX guides.

share|improve this answer

Your Answer


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.