Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Upstream] titled-frame wrong horizontal placement of both title and continuation label seen with higher border width #3

Closed
jfbu opened this issue Sep 24, 2022 · 2 comments
Labels
upstream bug Problems we feel are bugs of framed.sty

Comments

@jfbu
Copy link
Owner

jfbu commented Sep 24, 2022

If we modify titled-frame with an increased border-width, we see that not only title looks wrongly positioned but also continuation label. In the image, we see the continuation label because \smash does \leavevmode with recent LaTeX, otherwise it would have become invisible from being swallowed into the border.

I used

\renewenvironment{titled-frame}[1]{%
  \def\FrameCommand{\fboxsep8pt\fboxrule16pt
     \TitleBarFrame{\textbf{#1}}}%
  \def\FirstFrameCommand{\fboxsep8pt\fboxrule16pt
     \TitleBarFrame[\rule{4pt}{4pt}]{\textbf{#1}}}%
  \def\MidFrameCommand{\fboxsep8pt\fboxrule16pt
     \TitleBarFrame[\rule{4pt}{4pt}]{\textbf{#1\ (cont)}}}%
  \def\LastFrameCommand{\fboxsep8pt\fboxrule16pt
     \TitleBarFrame{\textbf{#1\ (cont)}}}%
  \MakeFramed{\advance\hsize-48pt \FrameRestore}}% 48=16+8+8+16
 {\endMakeFramed}

and obtained (the contents were trimmed to be sure they fit together with thick borders in linewidth, but anyhow the image showing only the frame, we do not see it fits exactly in the linewidth)
Capture d’écran 2022-09-24 à 15 31 58

I used a 4pt x 4pt rule as continuation label.

With colorframed (including fix of #2) we get this
Capture d’écran 2022-09-24 à 15 45 02

As commented in #2, the start of title is partly covered. The continuation label is configured here to use colour purple (as is used for TFTitleColor) and the \smash problem is fixed and we see the label in the border. But clearly this is wrong location.

I feel that at some point of development of framed.sty macro \TF@Title and \TF@conlab, it might be that D. A. had another \CustomFBox which would draw the vertical rules in such a way that the hboxes had their left border at the right edge of the west rule. Because if both Title and Continuation Label were shifted to the right by one \fboxrule more we would not have the above problems.

I had started commenting this in my edited \TF@Title but I am moving these comments here out of the colorframed.sty, so that they are recorded somewhere but don't take room in the macro file:

% The titled-frame environment depends in part on this macro,
% whose original in framed.sty has various colour problems.
% We have indicated the modifications, additionally to using
% our modified \CustomFBox.
% Original let the continuation label use same colour as frame.
% Let make this customizable.
\let\colorframedTFconlabcolorcommand\empty
\renewcommand\TitleBarFrame[3][]{\begingroup
  \ifx\delimiter#1\delimiter
    \let\TF@conlab\@empty
  \else
    \def\TF@conlab{%
     \nointerlineskip
     \hbox{%<<<< ADDED (needed due to \smash doing \leavevmode nowadays)
           \colorframedTFconlabcolorcommand%<<<< ADDED
% ADDED COMMENT (JFB, 2022/09/24)
% The horizontal placement of #1 done here is very likely a bug.  The
% \@tempboxa has a width which incorporates 2\fboxsep, but no \fboxrule.  The
% left boundary of hboxes is at **left** edge of left (west) border.  So this
% means that #1 is positioned to the right by \fboxsep of the **left** edge of
% the right (east) border.  For example if \fboxrule is much bigger than
% \fboxsep, this places the label entirely inside the border; and as
% framed.sty draws it with the frame colour, it becomes invisble.  Clearly a
% bug.  It should probably be here 2\fboxrule and then perhaps \fboxsep, or
% some other spacing.
%
% OR, PERHAPS: this code was done at time the \CustomFBox (the one of framed.sty)
% was done in such a way that reference point was to the right of the west
% border.  This would ALSO explain the problem with the \TF@Title placement of
% the title, see my github #2 for related comments.  I have been careful to
% check my analysis using pristine framed.sty, as things could have been
% caused by my own version of \CustomFBox, which boxes things differently.
     \smash{\rlap{\kern\wd\@tempboxa\kern\fboxrule\kern\fboxsep #1}}}%
          }%<<<< ADDED
  \fi
  %\let\TF@savecolor\current@color%<<<< REMOVED
  %\textcolor{TFFrameColor}{%      <<<< REMOVED
  \def\colorframedbordercolorcommand{\color{TFFrameColor}}%<<<< ADDED
  \CustomFBox
    {\TF@Title{#2}}{\TF@conlab}%
    \fboxrule\fboxrule\fboxrule\fboxrule
    {%\let\current@color\TF@savecolor\set@color%<<<< REMOVED
    #3}%
  %}%                              <<<< REMOVED
  \endgroup
}

Another issue we see above with the title is that its vertical placement looks poor when the border is thick like here.

@jfbu
Copy link
Owner Author

jfbu commented Sep 28, 2022

Decision has been made leave problematic original code unmodied. Commit 9bd2032 provides a possible replacement \colorframedTItleBarFrame to \TitleBarFrame. With it we get for example:
Capture d’écran 2022-09-28 à 17 42 54
(see file testissues3and4.tex)
This closes this issue and #4.

I will perhaps add a way to shift the title horizontally (here it is aligned with text) but that will be it.

jfbu added a commit that referenced this issue Sep 28, 2022
@jfbu
Copy link
Owner Author

jfbu commented Sep 28, 2022

I will perhaps add a way to shift the title horizontally (here it is aligned with text) but that will be it.

Done. Useful if environment is defined to use a large \fboxrule as in the screenshot of previous comment. It then makes the title align with the border with no separation, which is ok as the border is thick.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
upstream bug Problems we feel are bugs of framed.sty
Projects
None yet
Development

No branches or pull requests

1 participant