我使用制作图表draw.ioinkscape=true
我将其导出为 SVG 格式,以包含在我的 LaTeX 文档中。但是,有些文本太长,使用\includesvg
<path d="M 40 497 L 120 577" fill="none" stroke="#ff0000" stroke-miterlimit="10" pointer-events="none" />
<path d="M 120 497 L 40 577" fill="none" stroke="#ff0000" stroke-miterlimit="10" pointer-events="none" />
<rect x="400" y="597" width="80" height="80" fill="none" stroke="#ff0000" pointer-events="none" />
<rect x="400" y="597" width="80" height="80" fill="rgb(255, 255, 255)" stroke="#ff0000" pointer-events="none" />
<g transform="translate(-0.5 -0.5)">
<switch>
<foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility">
<div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe flex-start; justify-content: unsafe center; width: 1px; height: 1px; padding-top: 684px; margin-left: 440px;">
<div style="box-sizing: border-box; font-size: 0px; text-align: center;" data-drawio-colors="color: #FF0000; ">
<div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(255, 0, 0); line-height: 1.2; pointer-events: none; white-space: nowrap;">This text is wayyyyyyyyyy too long to fit under the square.</div>
</div>
</div>
</foreignObject>
<text x="440" y="696" fill="#FF0000" font-family="Helvetica" font-size="12px" text-anchor="middle">This text is wayyyyyyyyyy too long to fit under the square.</text>
</switch>
</g>
我将 SVG 包含在我的 LaTeX 文档中,就像这样(我使用考试文档类):
\framedsolutions\SolutionEmphasis{\bfseries\color{black}}
\begin{solutionorbox}[\stretch{1}]
\centering
\fontsize{8}{10}
\includesvg[inkscapelatex=true,width=\linewidth]{solution-schema-controle-5}
\end{solutionorbox}
有没有什么办法可以让换行的文字不超过正方形的宽度?
答案1
尝试将您的图像与盒子一起放入下一个构造中,如下所示:
\documentclass{article}
\usepackage{mwe} % new package from Martin scharrer
\usepackage{caption}
\begin{document}
\begin{figure}
\centering
\begin{minipage}[c]{\textwidth}
\centering
\includegraphics[width=0.3\linewidth]{example-image-a}
\caption{Caption for image}
\label{fig:sample_figure}
\end{minipage}
\end{figure}
\noindent
\begin{minipage}[c]{\textwidth}
\centering
\includegraphics[width=0.3\linewidth]{example-image-b}
\captionof{figure}{Caption for image}
\label{fig:sample_figure}
\end{minipage}
\end{document}
答案2
好的,我解决了这个问题,像这样手动修改了我的 SVG。而不是这行包含我的所有文本:
<text x="440" y="696" fill="#FF0000" font-family="Helvetica" font-size="12px" text-anchor="middle">This text is wayyyyyyyyyy too long to fit under the square.</text>
我<text>
使用 在标签内将其分开<tspan>
。请注意,sodipodi:role="line"
属性很重要,它告诉 Inkscape 此 tspan 不是内联的,而是代表单独的一行。
<text x="440" y="696" fill="#FF0000" font-family="Helvetica" font-size="12px" text-anchor="middle">
<tspan sodipodi:role="line" id="tspan100" style="font-size:12px" x="440" y="696">This text is</tspan>
<tspan sodipodi:role="line" id="tspan101" style="font-size:12px" x="440" y="696">wayyyyyyyyyy too long</tspan>
<tspan sodipodi:role="line" id="tspan102" style="font-size:12px" x="440" y="696">to fit under the square.</tspan>
</text>
结果如下: