Discussion:
[Scilab-users] LateX support and verbatim
Antoine Monmayrant
2016-08-26 13:00:29 UTC
Permalink
Hi all,

I tried to use verbatim text inside some latex string, but without success:

titlepage("$\verb| \alpha |$")

Is this normal?
Is "\verb" a TeX and not a LaTeX command?

Cheers,

Antoine
Samuel Gougeon
2016-08-26 15:08:36 UTC
Permalink
Hi Antoine,
Post by Antoine Monmayrant
Hi all,
titlepage("$\verb| \alpha |$")
Is this normal?
Is "\verb" a TeX and not a LaTeX command?
The previewer shows it in red => not supported. All LaTeX commands are
not supported.
\mbox{your text}
\text{..}
are.

Samuel
philippe
2016-08-27 17:24:46 UTC
Permalink
Hi,
Post by Antoine Monmayrant
Hi all,
titlepage("$\verb| \alpha |$")
since text are displayed as "verbatim" by scilab you don't need \verb ,
you should just write titlepage("\alpha").

Philippe.
Antoine Monmayrant
2016-08-28 07:46:39 UTC
Permalink
Post by philippe
Hi,
Post by Antoine Monmayrant
Hi all,
titlepage("$\verb| \alpha |$")
since text are displayed as "verbatim" by scilab you don't need \verb ,
you should just write titlepage("\alpha").
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.

Cheers,

Antoine
Post by philippe
Philippe.
_______________________________________________
users mailing list
http://lists.scilab.org/mailman/listinfo/users
Samuel Gougeon
2016-08-30 12:11:47 UTC
Permalink
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
jasper van baten
2016-08-30 12:30:56 UTC
Permalink
Hi Samuel,

Perhaps attaching scilab scripts to mail is not a good idea. In
combination with the file extension association and the 'host' command
this is prone to misuse.

Best wishes,

Jasper.
Post by Samuel Gougeon
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.
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.
* 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!
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()
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
_______________________________________________
users mailing list
http://lists.scilab.org/mailman/listinfo/users
Samuel Gougeon
2016-08-30 12:43:33 UTC
Permalink
.../...
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.
Another advantage of this version is that it takes into account void or
blank lines
set in the matrix of texts, whereas the default version removes all of them
(it likely assumes that the user that has set them does not really know what
he/she does. Poor user :)

SG

Loading...