How to display string variable without hanging texworks












2















I was getting unexpected results storing a parameter into a string variable, and added the statement "str_show:N l_tmpa_str" to produce debugging output. Texworks treats the output as an error. My first thought was to use str_log:N, but that does not exist.



My concerns are why I am getting an extraneous hyphen and quote around "semi-" and what the correct way is to get diagnostic output.



The reason for the extraneous characters in the underset is that the string functions and variablesare not intended for text that you need to render. Once I switched to token list variables for the text in the underset, everything worked.



documentclass{article}
usepackage{mathtools}
usepackage{xparse}

ExplSyntaxOn

% Render underscored with some variation of strict
NewDocumentCommand{strict}{O{strict} m}
{
show_strict:nn {#1} {#2}
}

cs_new_protected:Npn show_strict:nn #1 #2
{
str_set:Nn l_tmpa_str {#1}
l_tmpa_str~is~ l_tmpa_str
str_show:N l_tmpa_str
str_if_eq:eeTF {str_item:nn {#1} {-1}} {-}
{
str_set:Nx l_tmpa_str {{l_tmpa_str}strict}
}
{
str_case:nn {#1}
{
{*} {str_set:Nn l_tmpa_str {(semi-strict,strict)}}
{**} {str_set:Nn l_tmpa_str {semi-strict~(strict)}}
}
}
underset {textup{l_tmpa_str}} {#2}
}

ExplSyntaxOff

begin{document}

begin{enumerate}
item Test $strict{{default}}$ \*
expect underset with upright "strict"
item Test $strict[semi-]{{hyphen}}$
expect underset with upright "semi-strict"
item Test $strict[*]{{star}}$
expect underset with upright "(semi-strict,strict)"
item Test $strict[**]{{starstar}}$
expect underset with upright "semi-strict (strict)"
end{enumerate}

end{document}









share|improve this question




















  • 1





    You can use tl_log:N

    – egreg
    Feb 15 at 17:29











  • github.com/latex3/latex3/blob/master/l3kernel/CHANGELOG.md

    – egreg
    Feb 15 at 21:29
















2















I was getting unexpected results storing a parameter into a string variable, and added the statement "str_show:N l_tmpa_str" to produce debugging output. Texworks treats the output as an error. My first thought was to use str_log:N, but that does not exist.



My concerns are why I am getting an extraneous hyphen and quote around "semi-" and what the correct way is to get diagnostic output.



The reason for the extraneous characters in the underset is that the string functions and variablesare not intended for text that you need to render. Once I switched to token list variables for the text in the underset, everything worked.



documentclass{article}
usepackage{mathtools}
usepackage{xparse}

ExplSyntaxOn

% Render underscored with some variation of strict
NewDocumentCommand{strict}{O{strict} m}
{
show_strict:nn {#1} {#2}
}

cs_new_protected:Npn show_strict:nn #1 #2
{
str_set:Nn l_tmpa_str {#1}
l_tmpa_str~is~ l_tmpa_str
str_show:N l_tmpa_str
str_if_eq:eeTF {str_item:nn {#1} {-1}} {-}
{
str_set:Nx l_tmpa_str {{l_tmpa_str}strict}
}
{
str_case:nn {#1}
{
{*} {str_set:Nn l_tmpa_str {(semi-strict,strict)}}
{**} {str_set:Nn l_tmpa_str {semi-strict~(strict)}}
}
}
underset {textup{l_tmpa_str}} {#2}
}

ExplSyntaxOff

begin{document}

begin{enumerate}
item Test $strict{{default}}$ \*
expect underset with upright "strict"
item Test $strict[semi-]{{hyphen}}$
expect underset with upright "semi-strict"
item Test $strict[*]{{star}}$
expect underset with upright "(semi-strict,strict)"
item Test $strict[**]{{starstar}}$
expect underset with upright "semi-strict (strict)"
end{enumerate}

end{document}









share|improve this question




















  • 1





    You can use tl_log:N

    – egreg
    Feb 15 at 17:29











  • github.com/latex3/latex3/blob/master/l3kernel/CHANGELOG.md

    – egreg
    Feb 15 at 21:29














2












2








2








I was getting unexpected results storing a parameter into a string variable, and added the statement "str_show:N l_tmpa_str" to produce debugging output. Texworks treats the output as an error. My first thought was to use str_log:N, but that does not exist.



My concerns are why I am getting an extraneous hyphen and quote around "semi-" and what the correct way is to get diagnostic output.



The reason for the extraneous characters in the underset is that the string functions and variablesare not intended for text that you need to render. Once I switched to token list variables for the text in the underset, everything worked.



documentclass{article}
usepackage{mathtools}
usepackage{xparse}

ExplSyntaxOn

% Render underscored with some variation of strict
NewDocumentCommand{strict}{O{strict} m}
{
show_strict:nn {#1} {#2}
}

cs_new_protected:Npn show_strict:nn #1 #2
{
str_set:Nn l_tmpa_str {#1}
l_tmpa_str~is~ l_tmpa_str
str_show:N l_tmpa_str
str_if_eq:eeTF {str_item:nn {#1} {-1}} {-}
{
str_set:Nx l_tmpa_str {{l_tmpa_str}strict}
}
{
str_case:nn {#1}
{
{*} {str_set:Nn l_tmpa_str {(semi-strict,strict)}}
{**} {str_set:Nn l_tmpa_str {semi-strict~(strict)}}
}
}
underset {textup{l_tmpa_str}} {#2}
}

ExplSyntaxOff

begin{document}

begin{enumerate}
item Test $strict{{default}}$ \*
expect underset with upright "strict"
item Test $strict[semi-]{{hyphen}}$
expect underset with upright "semi-strict"
item Test $strict[*]{{star}}$
expect underset with upright "(semi-strict,strict)"
item Test $strict[**]{{starstar}}$
expect underset with upright "semi-strict (strict)"
end{enumerate}

end{document}









share|improve this question
















I was getting unexpected results storing a parameter into a string variable, and added the statement "str_show:N l_tmpa_str" to produce debugging output. Texworks treats the output as an error. My first thought was to use str_log:N, but that does not exist.



My concerns are why I am getting an extraneous hyphen and quote around "semi-" and what the correct way is to get diagnostic output.



The reason for the extraneous characters in the underset is that the string functions and variablesare not intended for text that you need to render. Once I switched to token list variables for the text in the underset, everything worked.



documentclass{article}
usepackage{mathtools}
usepackage{xparse}

ExplSyntaxOn

% Render underscored with some variation of strict
NewDocumentCommand{strict}{O{strict} m}
{
show_strict:nn {#1} {#2}
}

cs_new_protected:Npn show_strict:nn #1 #2
{
str_set:Nn l_tmpa_str {#1}
l_tmpa_str~is~ l_tmpa_str
str_show:N l_tmpa_str
str_if_eq:eeTF {str_item:nn {#1} {-1}} {-}
{
str_set:Nx l_tmpa_str {{l_tmpa_str}strict}
}
{
str_case:nn {#1}
{
{*} {str_set:Nn l_tmpa_str {(semi-strict,strict)}}
{**} {str_set:Nn l_tmpa_str {semi-strict~(strict)}}
}
}
underset {textup{l_tmpa_str}} {#2}
}

ExplSyntaxOff

begin{document}

begin{enumerate}
item Test $strict{{default}}$ \*
expect underset with upright "strict"
item Test $strict[semi-]{{hyphen}}$
expect underset with upright "semi-strict"
item Test $strict[*]{{star}}$
expect underset with upright "(semi-strict,strict)"
item Test $strict[**]{{starstar}}$
expect underset with upright "semi-strict (strict)"
end{enumerate}

end{document}






macros expl3 latex3 debugging






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Feb 18 at 15:47







shmuel

















asked Feb 15 at 17:23









shmuelshmuel

535211




535211








  • 1





    You can use tl_log:N

    – egreg
    Feb 15 at 17:29











  • github.com/latex3/latex3/blob/master/l3kernel/CHANGELOG.md

    – egreg
    Feb 15 at 21:29














  • 1





    You can use tl_log:N

    – egreg
    Feb 15 at 17:29











  • github.com/latex3/latex3/blob/master/l3kernel/CHANGELOG.md

    – egreg
    Feb 15 at 21:29








1




1





You can use tl_log:N

– egreg
Feb 15 at 17:29





You can use tl_log:N

– egreg
Feb 15 at 17:29













github.com/latex3/latex3/blob/master/l3kernel/CHANGELOG.md

– egreg
Feb 15 at 21:29





github.com/latex3/latex3/blob/master/l3kernel/CHANGELOG.md

– egreg
Feb 15 at 21:29










1 Answer
1






active

oldest

votes


















3














Yes, str_log:N and str_log:n were missing, but have been added for the next release, see https://github.com/latex3/latex3/blob/master/l3kernel/CHANGELOG.md and https://github.com/latex3/latex3/commit/83d2792ccf9e1c03b8a06e85c889d442da8e798c



In the meantime you can use tl_log:N, in your case it will log



> l_tmpa_str=strict.
> l_tmpa_str=semi-.
> l_tmpa_str=*.
> l_tmpa_str=**.





share|improve this answer
























  • I'm accepting your answer as a complete answer since it covered the most important part. I will edit my question to show the solution to the less important part.

    – shmuel
    Feb 18 at 15:43











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "85"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f475058%2fhow-to-display-string-variable-without-hanging-texworks%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









3














Yes, str_log:N and str_log:n were missing, but have been added for the next release, see https://github.com/latex3/latex3/blob/master/l3kernel/CHANGELOG.md and https://github.com/latex3/latex3/commit/83d2792ccf9e1c03b8a06e85c889d442da8e798c



In the meantime you can use tl_log:N, in your case it will log



> l_tmpa_str=strict.
> l_tmpa_str=semi-.
> l_tmpa_str=*.
> l_tmpa_str=**.





share|improve this answer
























  • I'm accepting your answer as a complete answer since it covered the most important part. I will edit my question to show the solution to the less important part.

    – shmuel
    Feb 18 at 15:43
















3














Yes, str_log:N and str_log:n were missing, but have been added for the next release, see https://github.com/latex3/latex3/blob/master/l3kernel/CHANGELOG.md and https://github.com/latex3/latex3/commit/83d2792ccf9e1c03b8a06e85c889d442da8e798c



In the meantime you can use tl_log:N, in your case it will log



> l_tmpa_str=strict.
> l_tmpa_str=semi-.
> l_tmpa_str=*.
> l_tmpa_str=**.





share|improve this answer
























  • I'm accepting your answer as a complete answer since it covered the most important part. I will edit my question to show the solution to the less important part.

    – shmuel
    Feb 18 at 15:43














3












3








3







Yes, str_log:N and str_log:n were missing, but have been added for the next release, see https://github.com/latex3/latex3/blob/master/l3kernel/CHANGELOG.md and https://github.com/latex3/latex3/commit/83d2792ccf9e1c03b8a06e85c889d442da8e798c



In the meantime you can use tl_log:N, in your case it will log



> l_tmpa_str=strict.
> l_tmpa_str=semi-.
> l_tmpa_str=*.
> l_tmpa_str=**.





share|improve this answer













Yes, str_log:N and str_log:n were missing, but have been added for the next release, see https://github.com/latex3/latex3/blob/master/l3kernel/CHANGELOG.md and https://github.com/latex3/latex3/commit/83d2792ccf9e1c03b8a06e85c889d442da8e798c



In the meantime you can use tl_log:N, in your case it will log



> l_tmpa_str=strict.
> l_tmpa_str=semi-.
> l_tmpa_str=*.
> l_tmpa_str=**.






share|improve this answer












share|improve this answer



share|improve this answer










answered Feb 15 at 21:32









egregegreg

721k8719123212




721k8719123212













  • I'm accepting your answer as a complete answer since it covered the most important part. I will edit my question to show the solution to the less important part.

    – shmuel
    Feb 18 at 15:43



















  • I'm accepting your answer as a complete answer since it covered the most important part. I will edit my question to show the solution to the less important part.

    – shmuel
    Feb 18 at 15:43

















I'm accepting your answer as a complete answer since it covered the most important part. I will edit my question to show the solution to the less important part.

– shmuel
Feb 18 at 15:43





I'm accepting your answer as a complete answer since it covered the most important part. I will edit my question to show the solution to the less important part.

– shmuel
Feb 18 at 15:43


















draft saved

draft discarded




















































Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f475058%2fhow-to-display-string-variable-without-hanging-texworks%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Biblatex bibliography style without URLs when DOI exists (in Overleaf with Zotero bibliography)

ComboBox Display Member on multiple fields

Is it possible to collect Nectar points via Trainline?