On March 28, 2003 02:44 am, Jean-Marc Lasgouttes wrote:
> >>>>> "Johnathan" == Johnathan Burchill <[EMAIL PROTECTED]> writes:
>
> Johnathan> Hi folks, I'm modifying a thesis.layout file to get it to
> Johnathan> approximate the dvi file a little closer.
>
> Johnathan> DVI: (<--...--> is just a placeholder for spacing)
> Johnathan> <---------------------------------> Chapter 1
> Johnathan> <--------------------------------> Introduction
>
> [...]
> Johnathan> Now I change the layout file to get the labels centered,
> Johnathan> with something like this: Style Chapter Align Center End
>
> Johnathan> LyX: Centered labels <----------------------------------->
> Johnathan> Chapter 1 <----------------------------------->
> Johnathan> Introduction
>
> Johnathan> I've searched the docs. Also the mailing list for "center
> Johnathan> Counter_Chapter" without success.
>
> This is a shortcoming of our label layout description syntax. I guess
> that what you describe should be the default when centering, but I am
> not sure it would be easy to obtain (this code is really horrible).
What do you mean by "this code is really horrible"?

Here is a patch that obtains the desired result in a couple of lines:
--- text.C.orig Fri Mar 28 11:58:24 2003
+++ text.C      Fri Mar 28 16:56:42 2003
@@ -3442,7 +3442,9 @@
                                                x = ww - leftMargin(p.bv, 
p.row) -
                                                        
font_metrics::width(str, font);
                                        }
-
+                                       if (layout->align == 
LYX_ALIGN_CENTER)
+                                               x = ww/2 - 
font_metrics::width(str, font)/2;
+
                                        p.pain->text(int(x),
                                                p.yo + p.row->baseline() -
                                                p.row->ascent_of_text() - 
maxdesc,

Apply it to src/text.C in LyX 1.3.1 to get the chapter label "Chapter N" 
centered over the chapter title in lyx window, when "Align Center" is 
defined in the chapter style part of your layout. I'm not aware of any 
side-effects. This should work for right-to-left (rtl) docs as well, but I 
haven't tested it. 

<snip>

That was fun. Cheers,
Johnathan
-- 
Johnathan K. Burchill, Ph.D. candidate
Department of Physics and Astronomy
University of Calgary
2500 University Drive N.W.
Calgary, AB T2N 1N4
Canada

(403) 217-4286
[EMAIL PROTECTED]

Reply via email to