LaTeXML
view release on metacpan or search on metacpan
lib/LaTeXML/Package/LaTeX.pool.ltxml view on Meta::CPAN
(role => $type . 'text', makeNoteTags($type, $_[1], $_[3] || Digest(T_CS('\the' . $type)))); },
reversion => '');
DefMacro('\footnote', '\lx@note{footnote}', locked => 1);
DefMacro('\footnotemark', '\lx@notemark{footnote}', locked => 1);
DefMacro('\footnotetext', '\lx@notetext{footnote}', locked => 1);
DefMacro('\@footnotetext', '\lx@notetext{footnote}', locked => 1);
# we don't implement the internals directly, so lock them to the latexml variant
Let('\@thefnmark', '\lx@notemark{footnote}', locked => 1);
Tag('ltx:note', afterClose => \&relocateFootnote);
# Find any pairs of footnotemark & footnotetext;
# Move the contents of the text to the mark, removing the text node.
sub relocateFootnote {
my ($document, $node) = @_;
if (($node->getAttribute('role') || '') =~ /^(\w+?)text$/) {
my $notetype = $1; # Eg "footnote", "endnote",...
if (my $mark = $node->getAttribute('mark')) {
foreach my $marknote ($document->findnodes(".//ltx:note[\@role='${notetype}mark'][\@mark='$mark']")) {
relocateFootnote_aux($document, $notetype, $marknote, $node); } } }
elsif (($node->getAttribute('role') || '') =~ /^(\w+?)mark$/) {
my $notetype = $1; # Eg "footnote", "endnote",...
if (my $mark = $node->getAttribute('mark')) {
foreach my $textnote ($document->findnodes(".//ltx:note[\@role='${notetype}text'][\@mark='$mark']")) {
relocateFootnote_aux($document, $notetype, $node, $textnote); } } }
return; }
# Move the contents of the $textnote to the $marknote, remove $textnote.
sub relocateFootnote_aux {
my ($document, $notetype, $marknote, $textnote) = @_;
$textnote->parentNode->removeChild($textnote);
$document->appendClone($marknote, $textnote->childNodes);
$document->setAttribute($marknote, role => $notetype);
if (my $labels = $textnote->getAttribute('labels')) {
GenerateID($document, $marknote);
$document->setAttribute($marknote, labels => $labels); }
return; }
# Style parameters
lib/LaTeXML/Package/amsppt.sty.ltxml view on Meta::CPAN
: (RefStepCounter('footnote'),
mark => DigestText(T_CS('\thefootnote')))) });
DefConstructor('\footnotetext[]{}',
"<ltx:note role='footnotetext' mark='#mark' xml:id='#id'>#2</ltx:note>",
mode => 'text',
properties => sub {
($_[1]
? (mark => $_[1])
: (mark => Digest(T_CS("\\thefootnote")))); });
Tag('ltx:note', afterClose => \&relocateFootnote);
sub relocateFootnote {
my ($document, $node) = @_;
if (($node->getAttribute('role') || '') =~ /^(\w+?)text$/) {
my $notetype = $1; # Eg "footnote", "endnote",...
if (my $mark = $node->getAttribute('mark')) {
if (my $note = $document->findnode(".//ltx:note[\@role='${notetype}mark'][\@mark='$mark']")) {
$node->parentNode->removeChild($node);
append_nodes($note, $node->childNodes);
$document->setAttribute($note, role => $notetype); } } }
return; }
lib/LaTeXML/Package/inst_support.sty.ltxml view on Meta::CPAN
NewCounter('inst', 'document');
DefMacro('\institute{}',
'\bgroup\setcounter{inst}{1}'
. '\let\and\institute@and\let\iand\institute@and\let\nand\institute@and\let\lastand\institute@and'
. '\let\at\institute@and' # Actually something quite different...?
. '\let\email\@in@inst@email\@new@institute#1\@end@institute\egroup');
DefMacro('\institute@and', '\@end@institute\stepcounter{inst}\@new@institute');
DefMacro('\@new@institute XUntil:\@end@institute', '\if.#1.\else\@add@institute{#1}\fi');
Let('\@end@institute', '\relax');
#should play similar game as with institute, relocate?
DefMacro('\emailname', 'E-mail');
DefConstructor('\@in@inst@email{}',
"<ltx:note role='email' name='#name' mark='#mark'>#1</ltx:note>",
properties => sub { (name => Digest(T_CS('\emailname')),
mark => ToString(Expand(T_CS('\theinst')))); });
# This creates the note for each institute.
DefConstructor('\@add@institute {}',
"<ltx:note role='institutetext' mark='#mark'>#1</ltx:note>",
bounded => 1, beforeDigest => sub { AssignValue(inPreamble => 0); },
properties => sub { (mark => ToString(Expand(T_CS('\theinst')))); });
# Reconnecting the institute to the appropriate author:
# [Handling is similar to reconnecting footnotemark & footnotetext]
Tag('ltx:note', afterClose => \&relocateInstitute);
sub relocateInstitute {
my ($document, $instnode) = @_;
if (($instnode->getAttribute('role') || '') eq 'institutetext') {
if (my $mark = $instnode->getAttribute('mark')) {
# Find authors with same mark.
my @authors;
if (@authors = $document->findnodes(".//ltx:contact[\@role='institutemark'][\@_mark='$mark']")) {
foreach my $author (@authors) {
$document->appendClone($author, $instnode->childNodes);
$author->setAttribute(role => 'institute');
$author->removeAttribute('_mark'); }
$instnode->parentNode->removeChild($instnode); }
# Not sure if this is right; find authors WITHOUT a contact mark.
elsif (@authors = $document->findnodes(".//ltx:creator[not(descendant::ltx:contact[\@role='institutemark'])]")) {
foreach my $author (@authors) {
$document->appendTree($author, ['ltx:contact', { role => 'institute' }, $instnode->childNodes]);
$instnode->parentNode->removeChild($instnode); } }
} }
# Or relocate email
if (($instnode->getAttribute('role') || '') eq 'email') {
if (my $mark = $instnode->getAttribute('mark')) {
# Find authors with same mark.
my @authors;
if (@authors = $document->findnodes(".//ltx:contact[\@role='emailmark'][\@_mark='$mark']")) {
foreach my $author (@authors) {
$document->appendClone($author, $instnode->childNodes);
$author->setAttribute(role => 'email');
$author->removeAttribute('_mark'); }
$instnode->parentNode->removeChild($instnode); }
lib/LaTeXML/Post.pm view on Meta::CPAN
if (my $fragid = $n->getAttribute('fragid')) { # GACK!!
$n->setAttribute(fragid => substr($newid, length($id) - length($fragid))); } }
# Now, replace all REFERENCES to those modified ids.
foreach my $n ($self->findnodes('descendant-or-self::*[@idref]', $copy)) {
if (my $id = $idmap{ $n->getAttribute('idref') }) {
$n->setAttribute(idref => $id); } } # use id or fragid?
# Finally, we probably shouldn't have any labels attributes in here either
foreach my $n ($self->findnodes('descendant-or-self::*[@labels]', $copy)) {
$n->removeAttribute('labels'); }
# And, if we're relocating the node across documents,
# we may need to patch relative pathnames!
# ????? Something to think about in the future...
# if(my $base = $options{basepathname}){
# foreach my $n ($self->findnodes('descendant::*/@graphic or descendant::*/@href', $copy)) {
# $n->setvalue(relocate($n->value,$base)); }}
return $copy; }
sub cloneNodes {
my ($self, @nodes) = @_;
return map { $self->cloneNode($_) } @nodes; }
sub addSSValues {
my ($self, $node, $key, $values) = @_;
$values = $values->toAttribute if ref $values;
if ((defined $values) && ($values ne '')) { # Skip if `empty'; but 0 is OK!
( run in 0.492 second using v1.01-cache-2.11-cpan-5511b514fd6 )