Removing commands from input to command












0















I'm trying to create my own command to highlight some changes. I want the command to update a counter, add a line in the contents table and do some changes in the text.



So far, I got:



DeclareRobustCommand{CoorAdd}[1]{%
refstepcounter{change}%
textcolor{blue}{#1}%
addcontentsline{tod}{subsection}{Correction arabic{change}. Added:
textcolor{blue}{substring{#1}{1}{20}}~% substring macro to cut the text to the first 20 characters
}
ignorespaces}


which works great as long as there is no commands in the input. If I write CoorAdd{ in figure Cref{fig.fig}}, it generates a bunch of errors such as:



Argument of @crefstar has an extra }. [...s.}}{1}{20}}nobreakspace {}}{10}{change.34}]
Paragraph ended before @crefstar was complete. [...s.}}{1}{20}}nobreakspace {}}{10}{change.34}]
Undefined control sequence. [...s.}}{1}{20}}nobreakspace {}}{10}{change.34}]
Undefined control sequence. [...s.}}{1}{20}}nobreakspace {}}{10}{change.34}]
Undefined control sequence. [...s.}}{1}{20}}nobreakspace


My question is: Is there a way to remove the commands from the input? Or maybe to de-command by removing the or similar. I don't mind to have some extra garbage text around.



Thanks in advance!



--- EDIT ---



I realised the problem is related to the command `substring', which does not accept commands in the input string. Anyway, I'm not using it anymore.



Therefore, I'm closing this question.



Thank all for your help and sorry for the bothering.



Solution : Remove the command substring










share|improve this question

























  • Try detokenize.

    – Hood Chatham
    Mar 27 at 20:14






  • 1





    Also, you should add a minimal working example. What are the packages you've loaded? Presumably cleveref and whatever packages provide substring and removeabs. The textcolor commands are probably unrelated to the problem -- have you tried removing them? What happens if you remove everything and just say addcontentsline{tod}{subsection}{#1}? Does it still break?

    – Hood Chatham
    Mar 27 at 20:17











  • Hi @HoodChatham thank for your comment. You made me consider the problem was with substring as indeed when I remove it, the command works perfectly.

    – Germán Martínez
    Mar 27 at 20:31











  • What does happen when you put protect in front of Cref ?I.e., CoorAdd{ in figure protectCref{fig.fig}}

    – Ulrich Diez
    Mar 28 at 1:52
















0















I'm trying to create my own command to highlight some changes. I want the command to update a counter, add a line in the contents table and do some changes in the text.



So far, I got:



DeclareRobustCommand{CoorAdd}[1]{%
refstepcounter{change}%
textcolor{blue}{#1}%
addcontentsline{tod}{subsection}{Correction arabic{change}. Added:
textcolor{blue}{substring{#1}{1}{20}}~% substring macro to cut the text to the first 20 characters
}
ignorespaces}


which works great as long as there is no commands in the input. If I write CoorAdd{ in figure Cref{fig.fig}}, it generates a bunch of errors such as:



Argument of @crefstar has an extra }. [...s.}}{1}{20}}nobreakspace {}}{10}{change.34}]
Paragraph ended before @crefstar was complete. [...s.}}{1}{20}}nobreakspace {}}{10}{change.34}]
Undefined control sequence. [...s.}}{1}{20}}nobreakspace {}}{10}{change.34}]
Undefined control sequence. [...s.}}{1}{20}}nobreakspace {}}{10}{change.34}]
Undefined control sequence. [...s.}}{1}{20}}nobreakspace


My question is: Is there a way to remove the commands from the input? Or maybe to de-command by removing the or similar. I don't mind to have some extra garbage text around.



Thanks in advance!



--- EDIT ---



I realised the problem is related to the command `substring', which does not accept commands in the input string. Anyway, I'm not using it anymore.



Therefore, I'm closing this question.



Thank all for your help and sorry for the bothering.



Solution : Remove the command substring










share|improve this question

























  • Try detokenize.

    – Hood Chatham
    Mar 27 at 20:14






  • 1





    Also, you should add a minimal working example. What are the packages you've loaded? Presumably cleveref and whatever packages provide substring and removeabs. The textcolor commands are probably unrelated to the problem -- have you tried removing them? What happens if you remove everything and just say addcontentsline{tod}{subsection}{#1}? Does it still break?

    – Hood Chatham
    Mar 27 at 20:17











  • Hi @HoodChatham thank for your comment. You made me consider the problem was with substring as indeed when I remove it, the command works perfectly.

    – Germán Martínez
    Mar 27 at 20:31











  • What does happen when you put protect in front of Cref ?I.e., CoorAdd{ in figure protectCref{fig.fig}}

    – Ulrich Diez
    Mar 28 at 1:52














0












0








0








I'm trying to create my own command to highlight some changes. I want the command to update a counter, add a line in the contents table and do some changes in the text.



So far, I got:



DeclareRobustCommand{CoorAdd}[1]{%
refstepcounter{change}%
textcolor{blue}{#1}%
addcontentsline{tod}{subsection}{Correction arabic{change}. Added:
textcolor{blue}{substring{#1}{1}{20}}~% substring macro to cut the text to the first 20 characters
}
ignorespaces}


which works great as long as there is no commands in the input. If I write CoorAdd{ in figure Cref{fig.fig}}, it generates a bunch of errors such as:



Argument of @crefstar has an extra }. [...s.}}{1}{20}}nobreakspace {}}{10}{change.34}]
Paragraph ended before @crefstar was complete. [...s.}}{1}{20}}nobreakspace {}}{10}{change.34}]
Undefined control sequence. [...s.}}{1}{20}}nobreakspace {}}{10}{change.34}]
Undefined control sequence. [...s.}}{1}{20}}nobreakspace {}}{10}{change.34}]
Undefined control sequence. [...s.}}{1}{20}}nobreakspace


My question is: Is there a way to remove the commands from the input? Or maybe to de-command by removing the or similar. I don't mind to have some extra garbage text around.



Thanks in advance!



--- EDIT ---



I realised the problem is related to the command `substring', which does not accept commands in the input string. Anyway, I'm not using it anymore.



Therefore, I'm closing this question.



Thank all for your help and sorry for the bothering.



Solution : Remove the command substring










share|improve this question
















I'm trying to create my own command to highlight some changes. I want the command to update a counter, add a line in the contents table and do some changes in the text.



So far, I got:



DeclareRobustCommand{CoorAdd}[1]{%
refstepcounter{change}%
textcolor{blue}{#1}%
addcontentsline{tod}{subsection}{Correction arabic{change}. Added:
textcolor{blue}{substring{#1}{1}{20}}~% substring macro to cut the text to the first 20 characters
}
ignorespaces}


which works great as long as there is no commands in the input. If I write CoorAdd{ in figure Cref{fig.fig}}, it generates a bunch of errors such as:



Argument of @crefstar has an extra }. [...s.}}{1}{20}}nobreakspace {}}{10}{change.34}]
Paragraph ended before @crefstar was complete. [...s.}}{1}{20}}nobreakspace {}}{10}{change.34}]
Undefined control sequence. [...s.}}{1}{20}}nobreakspace {}}{10}{change.34}]
Undefined control sequence. [...s.}}{1}{20}}nobreakspace {}}{10}{change.34}]
Undefined control sequence. [...s.}}{1}{20}}nobreakspace


My question is: Is there a way to remove the commands from the input? Or maybe to de-command by removing the or similar. I don't mind to have some extra garbage text around.



Thanks in advance!



--- EDIT ---



I realised the problem is related to the command `substring', which does not accept commands in the input string. Anyway, I'm not using it anymore.



Therefore, I'm closing this question.



Thank all for your help and sorry for the bothering.



Solution : Remove the command substring







macros robust-commands






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 29 at 11:17







Germán Martínez

















asked Mar 27 at 20:04









Germán MartínezGermán Martínez

478




478













  • Try detokenize.

    – Hood Chatham
    Mar 27 at 20:14






  • 1





    Also, you should add a minimal working example. What are the packages you've loaded? Presumably cleveref and whatever packages provide substring and removeabs. The textcolor commands are probably unrelated to the problem -- have you tried removing them? What happens if you remove everything and just say addcontentsline{tod}{subsection}{#1}? Does it still break?

    – Hood Chatham
    Mar 27 at 20:17











  • Hi @HoodChatham thank for your comment. You made me consider the problem was with substring as indeed when I remove it, the command works perfectly.

    – Germán Martínez
    Mar 27 at 20:31











  • What does happen when you put protect in front of Cref ?I.e., CoorAdd{ in figure protectCref{fig.fig}}

    – Ulrich Diez
    Mar 28 at 1:52



















  • Try detokenize.

    – Hood Chatham
    Mar 27 at 20:14






  • 1





    Also, you should add a minimal working example. What are the packages you've loaded? Presumably cleveref and whatever packages provide substring and removeabs. The textcolor commands are probably unrelated to the problem -- have you tried removing them? What happens if you remove everything and just say addcontentsline{tod}{subsection}{#1}? Does it still break?

    – Hood Chatham
    Mar 27 at 20:17











  • Hi @HoodChatham thank for your comment. You made me consider the problem was with substring as indeed when I remove it, the command works perfectly.

    – Germán Martínez
    Mar 27 at 20:31











  • What does happen when you put protect in front of Cref ?I.e., CoorAdd{ in figure protectCref{fig.fig}}

    – Ulrich Diez
    Mar 28 at 1:52

















Try detokenize.

– Hood Chatham
Mar 27 at 20:14





Try detokenize.

– Hood Chatham
Mar 27 at 20:14




1




1





Also, you should add a minimal working example. What are the packages you've loaded? Presumably cleveref and whatever packages provide substring and removeabs. The textcolor commands are probably unrelated to the problem -- have you tried removing them? What happens if you remove everything and just say addcontentsline{tod}{subsection}{#1}? Does it still break?

– Hood Chatham
Mar 27 at 20:17





Also, you should add a minimal working example. What are the packages you've loaded? Presumably cleveref and whatever packages provide substring and removeabs. The textcolor commands are probably unrelated to the problem -- have you tried removing them? What happens if you remove everything and just say addcontentsline{tod}{subsection}{#1}? Does it still break?

– Hood Chatham
Mar 27 at 20:17













Hi @HoodChatham thank for your comment. You made me consider the problem was with substring as indeed when I remove it, the command works perfectly.

– Germán Martínez
Mar 27 at 20:31





Hi @HoodChatham thank for your comment. You made me consider the problem was with substring as indeed when I remove it, the command works perfectly.

– Germán Martínez
Mar 27 at 20:31













What does happen when you put protect in front of Cref ?I.e., CoorAdd{ in figure protectCref{fig.fig}}

– Ulrich Diez
Mar 28 at 1:52





What does happen when you put protect in front of Cref ?I.e., CoorAdd{ in figure protectCref{fig.fig}}

– Ulrich Diez
Mar 28 at 1:52










0






active

oldest

votes












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%2f481782%2fremoving-commands-from-input-to-command%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















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%2f481782%2fremoving-commands-from-input-to-command%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

How to change which sound is reproduced for terminal bell?

Can I use Tabulator js library in my java Spring + Thymeleaf project?

Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents