We do recommend adding custom classes to your images if you're having trouble with image sizing in your PDFs. You can read more about that at https://pressbooks.com/2017/07/11/preparing-and-uploading-your-images-for-pressbooks-2/
However, when you add the custom class to change the size of the image, it effects the
itself, and not the image wrapper that is usually used to properly size the image. This makes the caption max-width: 100%. In other words, the caption will span the entire width of the page. You need to add custom css to change the caption width itself.
For centered images, you can target the caption by adding custom CSS:
.yourclass + .wp-caption-text, where
.yourclass represents the users class,
.wp-caption-text stays constant. Then, change the width to what you stated on the custom class.
You will also need to add a "margin-left: auto;" and "margin-right: auto;" to properly align the image.