4

Complete

alt text


Top Left Corner

alt text


Top Right Corner

alt text


Bottom Left Corner

alt text


Bottom Right Corner

alt text

\documentclass[dvipsnames,dvips,cmyk]{minimal}
\usepackage{xcolor,calc}
\usepackage[%
paperwidth=30mm,
paperheight=30mm,
textwidth=25mm,
textheight=25mm,
showframe]{geometry}
\setlength{\fboxsep}{5mm}
\setlength{\fboxrule}{5mm}
\usepackage{lipsum}
\begin{document}
\topskip0pt%
\noindent\color{red}\fbox{\parbox{\textwidth-2\fboxsep-2\fboxrule}{\color{green}\rule{5mm}{5mm}}}
\end{document}

EDIT 1:

Questions:

  1. These asymmetric frame rules are intentionally made or bugs?
  2. \textwidth equals to the horizontal distance between inner edges of the frame rules or outer edges of the frame rules?

EDIT 2:

  1. I think the frame enclosing the text content is created partially/separately using 4 rules rather than using \fbox (with \fboxsep set to zero, of course). Can it be changed to use \fbox ?

  2. If we use PSTrick's terminology in this discussion, I think the box enclosing the text content used dimen=inner, right? If it is right, then the \textwidth is measured as the horizontal distance between the inner edges of the box. Please kindly confirm whether or not my understanding is correct?


EDIT 3:

Except for the "asymmetric frame rules" produced by geometry.sty, my diagram below reproduce it with some annotations.

The frame produced by geometry.sty seems to expand outward. Thus, the \textwidth equals to horizontal distance between the inner edges of this frame.

Note: scale in mm.

alt text


This bug still exists.

Display Name
  • 46,933

3 Answers3

5

I'd say that the behaviour seen is a bug in geometry. LaTeX's \fbox also has to use four rules to achieve the effect, but these do join up correctly. So I'd report the issue to the author of geometry and see what he says.

On framing around \textwidth, the frame should be 'outside' of the material (i.e. the TeX box containing the material should actually have a width of \textwidth plus twice the width of the rule used). Again, this is certainly what \fbox does.

Joseph Wright
  • 259,911
  • 34
  • 706
  • 1,036
3

TeX always thinks in boxes. The reference point is the current point, which is at the start at the very left of each line. When TeX draws a fbox, it draws a vertical bar of width \fboxsep and increases the currentpoint with this value. Then it draws two horizontal rules each of a boxwidth of 0, the reason why the current point isn't increased. Then it inserts a space of \fboxsep which is the same as moving the current point to the right. Then the box contents is inserted and the current point is increased with the width of the box contents. Now the \fboxsepis added again, also with increasing the current point. And now the right vertical bar is drawn and the current point again increased by \fboxrule. The next box, if there is one, starts with its left side at the current point. See also slide 32ff of http://userpages.fu-berlin.de/~latex/PSTricks/DANTE2006.pdf. It is in german, but easy to see, what I mean by setting boxes.

  • thanks for your informative and useful answer. I choose @Joseph's answer to be Green-marked due to his compact answer. – Display Name Dec 25 '10 at 13:16
1

I cannot say, that I understand your problem. But here is a slightly changed code, which gives me an expected result:

\documentclass[cmyk]{minimal}
\usepackage{xcolor,calc}
\usepackage[%
paperwidth=30mm,
paperheight=30mm,
textwidth=25mm,
textheight=25mm,
showframe]{geometry}
\setlength{\fboxsep}{5mm}
\setlength{\fboxrule}{5mm}
\begin{document}
\noindent\color{red}\fbox{%
%  \parbox{\linewidth-2\fboxsep-2\fboxrule}{%
  \color{green}\rule{5mm}{5mm}%
%  }
}
\end{document}

alt text

  • specifying margin=0pt will result in Package geometry Warning: Over-specification inh'-direction. `width' (71.13188pt) is ignored.

    Package geometry Warning: Over-specification in v'-direction.height' (71.13188pt) is ignored. `. I will explain more detail in Edit 2 soon.

    – Display Name Dec 25 '10 at 08:36
  • 1
    you're right, it is nonsense, delete the margin=0pt –  Dec 25 '10 at 09:32