1

When I use an adjustbox around anything drawn with pstricks, the adjustbox just gets ignored. scalebox works, but requires manual tuning to determine the proper scaling factor (e.g., to scale something down so that it fits inside the margins, but no further). The following MWE illustrates:

\documentclass{article}

\usepackage{adjustbox}
\usepackage{pstricks}

\begin{document}
    \begin{adjustbox}{max width=\textwidth}
        \psline[linecolor=blue,linewidth=1.25pt](-6,2)(25,2)
    \end{adjustbox}
    
    \scalebox{0.5}{
        \psline[linecolor=blue,linewidth=1.25pt](-6,2)(25,2)
    }
\end{document}

This produces the following: enter image description here

Notice that the top line, which has the adjustbox around it, goes all the way to the page margins, while the identical lower line does not due to the scalebox around it. However, it is tricky to manually determine the right scaling factor to make a scalebox fit content precisely within the text area.

I do not want to scale images up to the text width; I just want to scale them down to no more than \textwidth if they exceed it. Is there a way to either make adjustbox work with pstricks drawings, or some alternative? I know adjustbox works with tikzpictures, but I specifically want to use pstricks for some things I'm doing.

5
  • your scalebox is intended by paragraph indent, and has a space before the rule, so two lots of white space at the left. but I think you want resizebox to textwidh not scalebox Sep 24, 2023 at 7:29
  • Ah, good point about the parindent. But the issue's still there if I add a \noindent in front of the scalebox. I've also just tried using \resizebox{\textwidth}{!}{...}, which produces a blank page (when the line inside adjustbox is commented out). Using \resizebox{\textwidth}{\textheight}{...} gives me the error Package graphics Error: Division by 0. Even if I could get resizebox working, wouldn't it scale the image up to \textwidth? I don't want to scale anything up, just down if it's too big.
    – Jigsaw
    Sep 24, 2023 at 16:02
  • All PSTricks objects have a width of 0pt. So it makes no sense to use a box command. What exactly do you want to do?
    – user187802
    Sep 25, 2023 at 20:00
  • My actual use case is using pst-jtree to draw syntax trees on slides. Some of the trees I want to draw can get a bit too wide or tall for the slides. I'd like to use adjustbox to scale them down to fit within the text width and text height, without having to run several compilations using \scalebox to manually determine the scaling factor, since having several trees can make each compilation take multiple minutes.
    – Jigsaw
    Sep 25, 2023 at 22:50
  • The fp package comes to my mind to solve yor problem. Sep 30, 2023 at 8:23

1 Answer 1

0
\documentclass{article}

\usepackage{showframe}
\usepackage{adjustbox}
\usepackage{pstricks,pst-jtree}
\parindent=0pt

\begin{document}
\begin{adjustbox}{max width=\textwidth}
\jtree
\! = <left>{A}!a ^<right>{B}.
\!a = <left>{C}!a ^<right>{D}.
\!a = <left>{E} ^<right>{F}.
\endjtree
\end{adjustbox}


\begin{adjustbox}{max width=\textwidth}
\psset{unit=15cm}% will be greater than text width
\jtree
\! = {A}
<vert>{\psframebox{B}}
:{C}{D}.
\endjtree
\end{adjustbox}

\end{document}

For the last example I didn't change the font size which depends not to the PSTricks scaling. This is the reason why it looks a bit curious ... :-)

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .