Skip to content

Commit 87bc31f

Browse files
anntzerQuLogic
authored andcommitted
Fix text.usetex when using xcolor in preamble.
1 parent 73b5101 commit 87bc31f

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

lib/matplotlib/dviread.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,18 +313,26 @@ def _read(self):
313313
# xxx comment
314314
# down
315315
# push
316-
# down, down
316+
# down
317+
# <push, push, xxx, right, xxx, pop, pop> # if using xcolor
318+
# down
317319
# push
318320
# down (possibly multiple)
319321
# push <= here, v is the baseline position.
320322
# etc.
321323
# (dviasm is useful to explore this structure.)
324+
# Thus, we use the vertical position at the first time the stack depth
325+
# reaches 3, while at least three "downs" have been executed, as the
326+
# baseline (the "down" count is necessary to handle xcolor).
327+
downs = 0
322328
self._baseline_v = None
323329
while True:
324330
byte = self.file.read(1)[0]
325331
self._dtable[byte](self, byte)
332+
downs += self._dtable[byte].__name__ == "_down"
326333
if (self._baseline_v is None
327-
and len(getattr(self, "stack", [])) == 3):
334+
and len(getattr(self, "stack", [])) == 3
335+
and downs >= 4):
328336
self._baseline_v = self.v
329337
if byte == 140: # end of page
330338
return True

0 commit comments

Comments
 (0)