TeX - LaTeX Asked by Dweeberly on February 23, 2021
Extreme TeX novice, sorry for the length of the example, I wasn’t sure what packages were important to replicate the problems. I was trying to create a simple command that I could use to injected labeled comments into an existing document. My comment would be in text color blue and be prefixed with initials (‘[XXX]’ in this example)
documentclass[12pt]{article}
usepackage{cprotect}
usepackage{amssymb, amsmath, bm, bbm}
usepackage{adjustbox}
usepackage{amsmath, amsfonts}
usepackage{bm, bbm}
usepackage{graphics, graphicx, color, epsf}
usepackage{natbib}
usepackage{xr, zref, hyperref}
usepackage{etoolbox, siunitx}
%
usepackage{xcolor}
%
usepackage{scrextend}
%
newcommandxxx[1] {newlinetextcolor{blue}{[XXX] #1}}
begin{document}
title{A title}
author{A person}
maketitle
section{A section}
Some section stuff
xxx{a comment}
begin{verbatim}
This is
text that
presented 'as-is'
end{verbatim}
Some more text
xxx{
abc
begin{verbatim}
verbatim
end{verbatim}
}
end{document}
Generates:
line 37: Argument of @xverbatim has an extra }. }
line 37: Paragraph ended before @xverbatim was complete. }
line 37: Extra }, or forgotten endgroup. }
: Emergency stop.
: Command @footnotemark has changed.
I tried to define a newenvironment (not shown) used by the command, thinking that perhaps the ‘command’ couldn’t handle nested content, but it didn’t help.
I’d like to understand what I have done wrong and how I might figure out such issues in the future.
Find a concise summary of the TeX syntax (not LaTeX, just basic basic TeX).
Understand how to get rid of that footnotemark warning. Is some package redefining that command?
You can probably use xparse's +v
-type-argument for having LaTeX read and tokenize everything in verbatim-category-code-régime and then passing things to scantokens
for re-tokenization, but if you do this, then xxx
cannot be used within macro-arguments/macro-definitions/etc:
documentclass[12pt]{article}
usepackage{xparse}
%
usepackage{xcolor}
%
begingroup
newcommandxxx[1]{%
endgroup
newcommandxxx{%
begingroup
catcode`^^I=12 %
innerxxx
}%
NewDocumentCommand{innerxxx}{+v}{%
endgroup
textcolor{blue}{[XXX] %
begingroup
newlinechar=endlinechar
scantokens{endgroup##1#1}}%
}%
}%
catcode`%=12relax
xxx{%}%
begin{document}
title{A title}
author{A person}
maketitle
section{A section}
Some section stuff
xxx{a comment}bla
begin{verbatim}
This is
text that
presented 'as-is'
end{verbatim}
Some more text
xxx{%
abc
begin{verbatim*}
verbatim
end{verbatim*}
}%
Indenting is funny when nesting verbatim-environment in verbatim-argument:
xxx{%
abc
begin{verbatim*}
verbatim
end{verbatim*}
}%
Indenting is funny when nesting verbatim-environment in verbatim-argument:
xxx{%
abc
begin{verbatim*}
verbatim
verbatim
end{verbatim*}
}%
end{document}
Correct answer by Ulrich Diez on February 23, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP