1

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

Stephen
  • 14,890
Kayla
  • 1,655

1 Answers1

6

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

  • 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? –  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 01: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 http://tex.stackexchange.com/questions/55437/how-do-i-update-my-tex-distribution/55473#55473 also –  Nov 15 '12 at 01: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 01:39
  • is there another way of creating the command without using the package mdframed? – Kayla Nov 15 '12 at 21:49
  • @kayla Search this site for information on installing texlive/packages in ubuntu. The above code contains other methods too. Only \myboxmd uses mdframed. –  Nov 15 '12 at 22:12