9

I'm trying to create a box as below in LaTeX.

\framebox[40em][c]{ I certify that the work presented in the dissertation is my own unless referenced.
}

I want a little bit padding between the text and the frame as shown in figure. I tried \vspace and putting line breaks at the beginning.

Also I can't put line breakers when I'm using \framebox to create the box. Can someone please advise me?

enter image description here

Heiko Oberdiek
  • 271,626

2 Answers2

9

\parbox or environment minipage can be used to put vertical material in a horizontal box like \fbox or \framebox:

\documentclass{article}
\begin{document}
\centering
\fbox{%
  \parbox{20em}{I certify that the work presented in the dissertation is
  my own unless referenced.}%
}

\medskip

\setlength{\fboxsep}{1em}
\fbox{%
  \parbox{20em}{I certify that the work presented in the dissertation is
  my own unless referenced.}%
}
\end{document}

Result

The padding is controled by dimen register \fboxsep and the line width of the frame by \fboxrule.

Heiko Oberdiek
  • 271,626
8

Another option is to use the tcolorbox package which easily gives you frames in which you can control the individual padding to the left, to the right, to the top and bottom, among many other attributes. A little example:

\documentclass{article}
\usepackage[most]{tcolorbox}

\newtcolorbox{myframe}[1][]{
  enhanced,
  arc=0pt,
  outer arc=0pt,
  colback=white,
  boxrule=0.8pt,
  #1
}

\title{The Title}
\author{The Author}

\begin{document}

\begin{myframe}
I certify that the work presented in the dissertation is my own unless referenced.
\end{myframe}

\begin{myframe}[width=30em]
I certify that the work presented in the dissertation is my own unless referenced.
\end{myframe}

\begin{myframe}[width=30em,top=10pt,bottom=10pt,left=20pt,right=20pt]
I certify that the work presented in the dissertation is my own unless referenced.
\end{myframe}

\begin{myframe}[width=30em,top=20pt,bottom=20pt,left=20pt,right=20pt,arc=10pt,auto outer arc]
I certify that the work presented in the dissertation is my own unless referenced.
\end{myframe}

\end{document} 

enter image description here

Gonzalo Medina
  • 505,128