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}?
  • 7
    Every LaTeX guide explains \underline and \fbox – egreg Nov 29 '12 at 16:24
  • 1
    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{document}\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.

|improve this answer|||||

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.