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 make a command to automate the creation of a box? This box would enclose texts or statements, questions and the like when the command is used. Example:

command and desired output

share|improve this question
1  
Perhaps a simple \fbox or something more sophisticated using mdframed? –  cmhughes Nov 13 '12 at 16:30
add comment

1 Answer 1

Using tikz, mdframed, \fbox and \framebox:

\documentclass{article}
\usepackage{tikz}
\usepackage[framemethod=default]{mdframed}
\newcommand{\mybox}[1]{%
\begin{tikzpicture}
\node[draw,rectangle,rounded corners=4pt,line width =1.5pt,text width=5cm,minimum width=5cm,minimum height=3cm]{#1};
\end{tikzpicture}
}
\newcommand{\myboxmd}[1]{%
\begin{mdframed}[linewidth=1.5pt]
#1\par
\end{mdframed}
}
\setlength{\fboxrule}{1.5pt}
\newcommand{\myboxframe}[1]{%
\framebox[.5\textwidth][t]{#1}
}
\begin{document}
\noindent
\mybox{Text is placed here}
\par\noindent
\myboxmd{Text is placed here}
\par
\noindent
\myboxframe{Text is placed here}
\par
\noindent
\fbox{Text is placed here}
\end{document}

enter image description here

share|improve this answer
    
when i compile this it gives me this error "! LaTeX Error: File `mdframed.sty found". –  Kayla Nov 14 '12 at 10:01
    
@kayla: Did you install mdframed? –  Harish Kumar Nov 14 '12 at 13:02
    
i tried to install in terminal Ubuntu by tlmgr install mdframed but it says: " No command tlmgr found, did you mean: Command vlmgr from package 'qdbm-util' (universe) Command 'rlmgr' from package 'qdbm-util' (universe) tlgmr: command not found". –  Kayla Nov 15 '12 at 1:25
    
@kayla: Search this site for installing such packages. I think you are using a tex distribution that came with your OS and not texlive. Refer to tex.stackexchange.com/questions/55437/… also –  Harish Kumar Nov 15 '12 at 1:27
    
I installed Tex Live 2009/Debian kpathsea version 5.0.0 in ubuntu 1204. How should i properly make the code above compile.. –  Kayla Nov 15 '12 at 1:39
show 2 more comments

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.