Cropping of TikZ images and labels

11 views
Skip to first unread message

Sean Fitzpatrick

unread,
Mar 24, 2021, 10:57:16 AM3/24/21
to APEX/Active Calculus MBX conversion
I've been coming across a few examples where labels are getting cut off in a TikZ image.

Here's an example: Exercise 4

This one's problematic, because the student needs the function in order to solve the problem.

Actually, there are two issues there:
1. There should be a caption with the function in it, for someone who can't see the image.
2. The image needs to be fixed.

I don't think this is a problem with cropping during the conversion script.
Instead, I think it's that the domain for the axes in the image ends too soon, and the label runs past the end of the domain.

No time to fix today, but this is something we might need to audit throughout the book.

Alex Jordan

unread,
Mar 24, 2021, 12:39:13 PM3/24/21
to apexactive-calcul...@googlegroups.com
There is a global pgfplots option for this. I think it is
"clipped=false". But if you use that, there will be an unwanted side
effect.

A pgfplots image is some default width, I forget what, but lets say
300pt. Right now, that 300pt is aligned with the axis width. Anything
that extends past, like the "^2" in that label is just not part of the
image. If you use clipped=false, then the width is still going to be
300pt, but everything is scaled down until that "^2" fits within that
width. In some images, that's fine. Here, alongside other similar
graphs, that will not look ideal.

Re:accessibility, a caption or other text with the function is not
enough on its own. The complete information about the bounds of the
shaded region is needed. Like in #5, saying its the region bounded
below by the x-axis, to the left by x=1, to the right by x=2, and
above by y=x. Probably that belongs in the alt test (PTX
"description").

I'm not feeling sure about things, but right now I would change the
labels like "y=x^2" to be anchored and positioned differently. So for
example, at (0.5,2.75), with a southwest anchor.

And only do this where immediately necessary. There is a discussion
that is formulating how to make tikz diagrams in a way that leads to
more accessible svgs that can be navigated. Something that would
clearly tell someone that "y=x^2" is a label for that curve element,
not just text floating in the image. If that gets worked out (and
someone has some time to spend, or a paid student to assign work to)
then it could be a larger project.
> --
> You received this message because you are subscribed to the Google Groups "APEX/Active Calculus MBX conversion" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to apexactive-calculus-mbx...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/apexactive-calculus-mbx-conversion/7e9005d4-39f7-4e59-8af4-1bd0ce8f9b2dn%40googlegroups.com.

Sean Fitzpatrick

unread,
Mar 24, 2021, 1:04:28 PM3/24/21
to apexactive-calcul...@googlegroups.com
Thanks. When I've spotted these in the past I think I just extended the
domain a little.
(E.g. adding 0.1 or 0.2 to the xrange.)

But moving the label would be better.

There are a number of images where I'm not happy with the label placement.
I suspect there may have been changes in newer versions of TikZ or pgfplots,
because I don't remember being annoyed by label placement in the old
LaTeX versions,
and most of the code is the same.

Rob Beezer

unread,
Mar 24, 2021, 1:59:03 PM3/24/21
to apexactive-calcul...@googlegroups.com
On 3/24/21 9:37 AM, Alex Jordan wrote:
> There is a discussion
> that is formulating how to make tikz diagrams in a way that leads to
> more accessible svgs that can be navigated.

Not just a discussion! Working on implementation right *now*. Labels are
extracted, math replaced by Unicode braille, and now feeding to liblouis to get
Grade 1 braille for the non-math bits........

Better placement is a beneficial side-effect of placing labels better for
tactile graphics.

Rob

Alex Jordan

unread,
Mar 24, 2021, 2:03:31 PM3/24/21
to apexactive-calcul...@googlegroups.com
Some of the label positions you might not like might be because I
occasionally associate a label with what it is labeling, and if it
looks "good enough" I let it go. Previously, it might have been a
situation where the label was just positioned absolutely. So it may
have looked "perfect" but there was nothing in the code that really
made that association. With more attention to detail, it's possible to
have your cake and eat it to.
> --
> You received this message because you are subscribed to the Google Groups "APEX/Active Calculus MBX conversion" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to apexactive-calculus-mbx...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/apexactive-calculus-mbx-conversion/1d40fed3-2c82-c738-b34e-9ee56b1f5b6c%40gmail.com.

Sean Fitzpatrick

unread,
Mar 24, 2021, 2:34:02 PM3/24/21
to APEX/Active Calculus MBX conversion
Ah, that could be it. I noticed with that incorrect image spotted by Grady that the original code had separate lines of code for the labels, with placement according to the axis coordinate system, rather than attaching the labels to the item being labelled

Alex Jordan

unread,
Mar 25, 2021, 2:07:59 PM3/25/21
to apexactive-calcul...@googlegroups.com
The other thing about this: once you decide to logically associate a
label to one of the graphical objects (and you don't have the advanced
approach Rob posted about) you might have a graph where the
positioning looks good in PDF output. But in HTML, it looks bad,
because of the general differences we see with latex-image images for
one output form versus the other.

Hopefully the new approach to accessible tikz images leads to both
things looking good (enough?) automatically.
> --
> You received this message because you are subscribed to the Google Groups "APEX/Active Calculus MBX conversion" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to apexactive-calculus-mbx...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/apexactive-calculus-mbx-conversion/CAH%2BNcPYBiLydVWrajHs8KQbTEwL-AG-pvXb1QSw-azTn1j_S8g%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages