> how can I use accentuated letters in substring function with luamplib ?
> I tried this code, but It doesn't work. I knew the problem with accentuated
> letters. But I search how to use it with substring.
You will have to re-implement ‘substr of’ with a lua function. The example
below shows how to do it with minim-mp; I am sure the same can be done with
luamplib in a similar way.
----------------------------------------------------------
\documentclass{article}
\usepackage[luamplib]{minim-mp} % note change of package
\begin{document}
\begin{mplibcode}
% create a utf8 lua subscript function
runscript ("function utfsubstring(s,f,t)" &
"return quote(string.sub(s,utf8.offset(s,f+1)," &
"utf8.offset(s,t+1)-1)) end");
beginfig(1);
string Test;
Test:="AaeéB";
% re-define substring
def substring expr c of s =
luafunction utfsubstring(s, xpart c, ypart c)
enddef;
% your example
string s;
for k=0 upto (length Test-2): % note the change from -1 to -2
label.top(TEX(substring(k,k+1) of Test), (k*1cm,0));
endfor;
endfig;
\end{mplibcode}
\end{document}
----------------------------------------------------------
Note that you will also have to re-implement ‘length’ for your example to work
(above, I changed the end condition of the for loop by hand instead).
Cordialement, Esger Renkema