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.

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.

share|improve this question
1  
What is the question? –  Stefan Kottwitz Dec 24 '10 at 16:56
    
@Stefan, please kindly see my edit 1. Thanks. –  xport Dec 24 '10 at 17:04
1  
no, more a dimen=outer. The width of a fbox is 2`\fboxrule 2 \fboxsepand the contents of the box. See my answer to placing boxes. –  Herbert Dec 25 '10 at 10:07
    
@Herbert, I am preparing a diagram to visually explain what I mean. It also will avoid misunderstanding. I hope 1 hours from now, I can upload the diagram for Edit 3. –  xport Dec 25 '10 at 10:18
1  
the image is correct. The textwidth and height is given first. Around that geometry draws the border. –  Herbert Dec 25 '10 at 12:05
show 3 more comments

3 Answers

up vote 4 down vote accepted

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.

share|improve this answer
    
Thank for quick reply. Both your answer and @Herbert's are understandable. I choose yours due to the simplicity. –  xport Dec 25 '10 at 13:14
add comment

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.

share|improve this answer
    
thanks for your informative and useful answer. I choose @Joseph's answer to be Green-marked due to his compact answer. –  xport Dec 25 '10 at 13:16
add comment

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

share|improve this answer
    
specifying margin=0pt will result in Package geometry Warning: Over-specification in h'-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. –  xport Dec 25 '10 at 8:36
1  
you're right, it is nonsense, delete the margin=0pt –  Herbert Dec 25 '10 at 9:32
add comment

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.