/usr/share/perl5/LaTeXML/Package/graphics.sty.ltxml is in latexml 0.8.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 | # -*- CPERL -*-
# /=====================================================================\ #
# | graphics | #
# | Implementation for LaTeXML | #
# |=====================================================================| #
# | Part of LaTeXML: | #
# | Public domain software, produced as part of work done by the | #
# | United States Government & not subject to copyright in the US. | #
# |---------------------------------------------------------------------| #
# | Bruce Miller <bruce.miller@nist.gov> #_# | #
# | http://dlmf.nist.gov/LaTeXML/ (o o) | #
# \=========================================================ooo==U==ooo=/ #
#**********************************************************************
package LaTeXML::Package::Pool;
use strict;
use warnings;
use LaTeXML::Package;
use LaTeXML::Util::Pathname;
use LaTeXML::Util::Image;
#======================================================================
# (See LaTeXML::Post::Graphics for suggested postprocessing)
# Package options: draft, final, hiderotate, hidescale, hiresbb
DefParameterType('GraphixDimension', sub {
my ($gullet) = @_;
if ($gullet->ifNext(T_OTHER('!'))) {
$gullet->readToken();
Dimension(0); }
else {
$gullet->readDimension; } });
DefConstructor('\scalebox{}[] Digested',
"<ltx:inline-block angle='#angle' width='#width' height='#height' depth='#depth'"
. " innerwidth='#innerwidth' innerheight='#innerheight' innerdepth='#innerdepth'"
. " xscale='#xscale' yscale='#yscale'"
. " xtranslate='#xtranslate' ytranslate='#ytranslate'>"
. "#3"
. "</ltx:inline-block>",
properties => sub {
my ($stomach, $xscale, $yscale, $box) = @_;
$xscale = ToString($xscale);
$yscale = ($yscale ? ToString($yscale) : $xscale);
my ($w, $h, $d) = $box->getSize;
return () unless $w;
(width => $w->multiply($xscale),
height => $h->multiply($yscale),
depth => $d->multiply($yscale),
xscale => $xscale,
yscale => $yscale,
xtranslate => $w->multiply(($xscale - 1) / 2),
ytranslate => $h->add($d)->multiply(($yscale - 1) / 2)); },
mode => 'text');
DefConstructor('\resizebox OptionalMatch:* {GraphixDimension}{GraphixDimension} Digested', sub {
my ($document, $star, $width, $height, $box, %props) = @_;
insertBlock($document, $box,
width => $props{width},
height => $props{height},
depth => $props{depth}); }, # ?
properties => sub {
my ($stomach, $star, $width, $height, $box) = @_;
(($width ? (width => $width) : ()),
($height ? (height => $height) : ()),
depth => Dimension(0)); }, # ?
mode => 'text');
# TeX wants to rotate CCW about the left edge of the box, at the baseline.
# CSS3's rotation wants to rotate CW about the center of the box!
# The resulting box should have it's origin at the leftmost corner
# But we're shifting the box from the position CSS thought that it WAS (before rotation!)
# However, I THINK that it is using the GIVEN width & height
# to determine the center!
sub rotatedProperties {
my ($angle, $box, $zero) = @_;
$angle = $angle->valueOf if ref $angle;
my $cwangle = -$angle;
my ($width, $height, $depth) = $box->getSize;
return () unless $width;
my ($w, $h, $d) = map { $_->valueOf } $width, $height, $depth;
my $H = $h + $d;
my $rad = $angle * 3.1415926 / 180; # close enough
my $s = sin($rad);
my $c = cos($rad);
my $wp = abs($w * $c) + abs($H * $s);
my $hp = max($c * $h + $s * $w, -$c * $d + $s * $w, -$c * $d, $c * $h);
my $dp = max($c * $d, -$c * $h, -$c * $h - $s * $w, $c * $d - $s * $w);
my $xsh = Dimension(($wp - $w) / 2)->ptValue . 'pt';
my $ysh = Dimension(($hp + $dp - $h - $d) / 2)->ptValue . 'pt';
if ($zero) {
# $wp = $hp = $dp = 0; }
$wp = 0; }
my $widthp = Dimension($wp);
my $heightp = Dimension($hp);
my $depthp = Dimension($dp);
## print STDERR "\nROTATE $angle of ".ToString($box)."\n"
## ." == ".ToString($width).' x '.ToString($height).' + '.ToString($depth)."\n"
## ." => ".ToString($widthp).' x '.ToString($heightp).' + '.ToString($depthp)."\n";
return (
angle => $angle,
width => $widthp,
height => $heightp,
depth => $depthp,
innerwidth => $width,
innerheight => $height,
innerdepth => $depth,
xtranslate => $xsh,
ytranslate => $ysh,
); }
DefConstructor('\rotatebox{Float} Digested',
"<ltx:inline-block angle='#angle' width='#width' height='#height' depth='#depth'"
. " innerwidth='#innerwidth' innerheight='#innerheight' innerdepth='#innerdepth'"
. " xscale='#xscale' yscale='#yscale'"
. " xtranslate='#xtranslate' ytranslate='#ytranslate'>"
. "#2"
. "</ltx:inline-block>",
afterDigest => sub {
my ($stomach, $whatsit) = @_;
$whatsit->setProperties(rotatedProperties($whatsit->getArg(1), $whatsit->getArg(2))); });
DefConstructor('\reflectbox Digested',
"<ltx:inline-block angle='#angle' width='#width' height='#height' depth='#depth'"
. " innerwidth='#innerwidth' innerheight='#innerheight' innerdepth='#innerdepth'"
. " xscale='#xscale' yscale='#yscale'"
. " xtranslate='#xtranslate' ytranslate='#ytranslate'>"
. "#1"
. "</ltx:inline-block>",
properties => sub {
my ($stomach, $box) = @_;
my ($w, $h, $d) = $box->getSize;
return () unless $w;
(width => $w,
height => $h,
depth => $d,
xscale => -1,
yscale => 1); },
mode => 'text');
DefConstructor('\graphicspath DirectoryList', sub {
my ($document, $paths) = @_;
foreach my $dir ($paths->getValues) {
my $path = pathname_absolute(pathname_canonical(ToString($dir)));
$document->insertPI('latexml', graphicspath => $path); } });
# Basically, we're transforming the graphics options into graphicx format.
DefMacro('\includegraphics OptionalMatch:* [][] Semiverbatim',
'\@includegraphics#1[#2][#3]{#4}');
DefConstructor('\@includegraphics OptionalMatch:* [][] Semiverbatim',
"<ltx:graphics graphic='#graphic' candidates='#candidates' options='#options'/>",
properties => sub {
my ($stomach, $starred, $op1, $op2, $graphic) = @_;
my $bb = ($op2 ? ToString($op1) . " " . ToString($op2) : ($op1 ? "0 0 " . ToString($op1) : ''));
$bb =~ s/,/ /g;
my $options = ($starred ? ($bb ? "viewport=$bb, clip" : "clip") : '');
$graphic = ToString($graphic); $graphic =~ s/^\s+//; $graphic =~ s/\s+$//;
my @candidates = pathname_findall($graphic, types => ['*'], paths => LookupValue('GRAPHICSPATHS'));
if (my $base = LookupValue('SOURCEDIRECTORY')) {
@candidates = map { pathname_relative($_, $base) } @candidates; }
(graphic => $graphic,
candidates => join(',', @candidates),
options => $options,
sizer => sub { \&image_graphicx_sizer }); },
alias => '\includegraphics');
# Also unimplemented... probably nothing useful to pass thru anyway?
DefConstructor('\DeclareGraphicsExtensions{}', '');
DefConstructor('\DeclareGraphicsRule{}{}{} Undigested', '');
# Nothing done about the keyval package...
#======================================================================
1;
|