TransWikia.com

How to scale everything but the font in an includestandalone tikz file?

TeX - LaTeX Asked by optional on January 5, 2021

Consider the following main.tex and figure/example.tex file.

% !TeX root = main.tex
documentclass{scrbook}

usepackage[subpreambles=true]{standalone}
usepackage{showframe}

begin{document}
chapter{Introduction}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris pharetra mauris at eleifend dictum. Sed vel velit rhoncus augue tempus commodo. Duis consectetur venenatis aliquet. Vivamus sodales elit vulputate, sagittis nunc at, dapibus eros. Proin commodo ac nibh a placerat. Proin consequat quam quis rutrum vestibulum. Donec nisi lacus, malesuada sit amet pellentesque nec, suscipit id turpis. Nullam ut ultrices dui.

begin{figure}[h!]
    includestandalone[mode=tex,width=textwidth]{figure/example}
end{figure}

end{document}

The code within the onlyifstandalone{...} command was taken from here and shows the size of the text area of the KOMA-Script document.

%!TeX root = example.tex
documentclass[
    tikz,
    class=scrbook,
    headinclude,fontsize=12pt
]{standalone}

usepackage{tikz}

onlyifstandalone{
    storeareasstandalonelayout% save the standalone layout
    recalctypearea% recalculate the typearea layout
    edefsavedtextheight{thetextheight}% save the text height of the typearea layout
    standalonelayout% restore the standalone layout
    
    % draw a red rectangle aligned with the upper left corner of the TikZ picture
    % to show the size of the text area in the KOMA document:
    tikzset{
        every picture/.append style={
            execute at end picture={%
                draw[red](current bounding box.north west)
                rectangle
                ++(thetextwidth,-savedtextheight);%
    }}}
}

begin{document}
begin{tikzpicture}
    node[style={text width=thetextwidth}] (example) at (0,0) {Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris pharetra mauris at eleifend dictum. Sed vel velit rhoncus augue tempus commodo. Duis consectetur venenatis aliquet. Vivamus sodales elit vulputate, sagittis nunc at, dapibus eros. Proin commodo ac nibh a placerat. Proin consequat quam quis rutrum vestibulum. Donec nisi lacus, malesuada sit amet pellentesque nec, suscipit id turpis. Nullam ut ultrices dui.};
    draw (example.south west) circle (2cm);
    draw (0,0) rectangle (example.north east);
end{tikzpicture}
end{document}

If I compile main.tex using pdflatex.exe --shell-escape -synctex=1 -interaction=nonstopmode "main".tex the resulting main.pdf looks like this:

Result of compilation

How do I scale the figure/example.tex file to textwidth without scaling the font?

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP