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.

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
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{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
add comment

1 Answer

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.

\documentclass{exam}

\usepackage{amsmath}

\begin{document}
\begin{questions}
\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$}?
\end{questions}
\begin{equation*}
\end{equation*}
\end{document}

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
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.