Hi Antoine,
Post by Antoine Monmayrant../..
Thanks Philippe, but nope, it does not work that easily.
It does for "\alpha", but my real use case is a bit more complicated and calling titlepage directly is a mess.
I use titlepage(errormessage) where errormessage is a string array with a lot of starting and trailing " " (white spaces).
I need to preserve these white spaces and use a monospace font to preserve the relative alignment between the different lines in the array.
- add some character at the begining of each line (to prevent titlepage from stripping the white spaces),
- call titlepage,
- get a handle the the create textbox,
- change text justification (middle->lef centered)
- change font style (0 for monospace).
This is what I use now, but titlepage("$\verb| error message |$") would have been more compact and elegant.
.
I definitely agree on the fact that xstring() (and xstringb(), called by
titlepage(),
and that are the guilty guys) always trimming all leading spaces is an
issue.
It should be the user's responsability to use stripblanks() whenever it
is required
before feeding xstring(), and that xstring() does not always do that in an
irreversible way (text stored in xstring.text is actually deblanked).
Presently, the text.alignment property can be either "left", "center"
and "right",
the default being "left".
IMO, a new *"as_is"* or *"none"* value should be added, and even become
the default.
For the time being, you may test and use the attached version of titlepage:
As soon as at least one of the strings has a leading space, the whole matrix
of strings is displayed "as is", in order to preserve any indentations
and so.
To do so, strings are displayed in LaTeX mode. Run
--> head_comments titlepage // to get details, or see the header in the
script.
This workaround has 2 drawbacks:
* lines are more compact (IMO too compact). I did not find any way to
tune this in supported LaTeX.
* The font style must be set when calling titlepage(). It can't be
changed with text.font_style,
and must be chosen when calling titlepage(). And only 3 fonts are
available.
But the text.font_foreground attribute works!
Example:
t = ["Here are indented nested lists"
" a) First point"
" * First item"
" * Second item"
" b) Another view"
" c) For a new titlepage()?"
]
clf
subplot(2,2,1)
titlepage(t)
xtitle("Default titlepage(t)")
subplot(2,2,2)
// exec() the new titlepage.sci
titlepage(t)
subplot(2,2,3)
titlepage([t ; "" ; t])
head_comments titlepage
subplot(2,2,4)
titlepage(t,0)
e = gce();
e.font_foreground = color("blue");
clear titlepage // comes back to the default titlepage()
*Results*:
This can be proposed as is to upgrade the present titlepage(),
even if it would be better to implement ASAP an "as_is" value for
xstring.alignment.
Cheers
Samuel