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.

can someone tell me how to fine position the text inside a dashbox. I have the following MWE:

\documentclass[12pt]{article}                               
\usepackage{graphicx}       

\begin{document}

\begin{picture}(380,320)

\put(10,0){\dashbox{2.5}(360,100)[tl] {Core-Standards}}

\end{picture}

\end{document}

It doesn´t look good I want the text top left but it intersects with the dotted square, I want the text a little bit to the right and down:

enter image description here

share|improve this question

3 Answers 3

up vote 6 down vote accepted

You can insert a vertical \strut and some horizontal space using (say) \,:

enter image description here

\documentclass[12pt]{article}                               
\usepackage{graphicx}% http://ctan.org/pkg/graphicx
\begin{document}
\begin{picture}(380,320)
  \put(10,0){\dashbox{2.5}(360,100)[tl] {Core-Standards (original)}}
  \put(10,110){\dashbox{2.5}(360,100)[tl] {\strut\,Core-Standards (updated)}}
\end{picture}
\end{document}

If you wish to push it down even further, you can increase the strut to the height you want with \rule{0pt}{<height>} where you specify <height>. \strut has a <height> of .7\baselineskip (and is therefore font-dependent).

Horizontal adjustment is possible using \rule{<width>}{0pt}. \, inserts a horizontal space of width \thinskipamount. Using \hspace*{<width>} would also work.

share|improve this answer
    
Thank you very much Werner, now it finally looks like I want it. –  chris Nov 29 '12 at 19:44

The following example defines and uses \padbox that adds a padding using \fbox with an invisible border (rule width set to zero). Also care is taken, that \fbox is working within the argument of \padbox. This way the text is surrounded with white space on all sides and avoids the clashing into any border of the dash box. The padding can be configured by setting the length \padboxsep. It is initialized with the value of \fboxsep.

\documentclass[12pt]{article}
\usepackage{graphicx}

\newdimen\padboxsep
\setlength{\padboxsep}{\fboxsep}
\newcommand*{\padbox}[1]{%
  \begingroup
    \edef\restorefbox{%
      \fboxrule=\the\fboxrule\relax
      \fboxsep=\the\fboxsep\relax
    }%
    \fboxrule=0pt %
    \fboxsep=\padboxsep
    \fbox{\restorefbox#1}%
  \endgroup
}

\begin{document}

\begin{picture}(380,320)

\put(10,110){\dashbox{2.5}(360,100)[tl] {Core-Standards \fbox{original}}}

\put(10,0){\dashbox{2.5}(360,100)[tl] {\padbox{Core-Standards \fbox{padbox}}}}

\end{picture}

\end{document}

Result

share|improve this answer
\documentclass{article}
\usepackage{pict2e}

\begin{document}
\setlength{\unitlength}{1mm} % set the unit of picture environment

\begin{picture}(0,0)
  \dashbox{1}(50,20)[c]{your text her}
\end{picture}

% (50,20) : this correspond to width and height of the dashbox
% [c] : this correspond to text adjustment, you can use [l] or [r] ...  

\end{document}
share|improve this answer

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.