[Scilab-users] titlepage() <= LateX support and verbatim

Samuel Gougeon sgougeon at free.fr
Tue Aug 30 14:11:47 CEST 2016


Hi Antoine,

Le 28/08/2016 09:46, Antoine Monmayrant a écrit :
> Le Samedi, Août 27, 2016 19:24 CEST, philippe <rouxph.22 at gmail.com> a écrit:
> ../..
> 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.
> Doing this is a bit convolved when using titlepage alone:
>   - 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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20160830/e7e1be84/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: heceeafg.png
Type: image/png
Size: 33930 bytes
Desc: not available
URL: <https://lists.scilab.org/pipermail/users/attachments/20160830/e7e1be84/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: titlepage.sci
Type: text/x-matlab
Size: 4508 bytes
Desc: not available
URL: <https://lists.scilab.org/pipermail/users/attachments/20160830/e7e1be84/attachment.bin>


More information about the users mailing list