我有pgf-pie
一张带图例的图表。其中一个条目太长,页面容不下,常规 LaTeX 换行命令似乎不起作用。
梅威瑟:
\documentclass[tikz, 12pt, a4paper]{report}
\usepackage[T1]{fontenc}
\usepackage{caption}
\usepackage{subcaption}
\usepackage[usenames, dvipsnames, rgb]{xcolor}
\usepackage{tikz}
\usepackage{pgf-pie}
\usetikzlibrary{arrows, positioning, shadows}
\begin{document}
\begin{figure}[!htbp]
\centering
\begin{tikzpicture}
\pie[sum=auto,text=legend]{52/blah, 36/{blah blah}, 18/{blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah}}
\end{tikzpicture}
\end{figure}
\end{document}
图例条目能以某种方式分成两行吗?
答案1
嗯,对于这种特殊情况来说,这是一个相当粗鲁的解决方案。只有当多行文本位于最后一行图例中时,它才有效。
\documentclass[12pt, a4paper]{report}
\usepackage[T1]{fontenc}
\usepackage{caption}
\usepackage{subcaption}
\usepackage[usenames, dvipsnames, rgb]{xcolor}
\usepackage{tikz}
\usetikzlibrary{arrows,
positioning,
shadows}
\usepackage{pgf-pie}
\begin{document}
\begin{figure}[!htbp]
\centering
\begin{tikzpicture}[
pie-label/.style = {text width=54mm, align=left,
anchor=north west, inner xsep=0pt}
]
\pie[sum=auto,text=legend]{52/blah, 36/{blah blah},
18/{\tikz[baseline=4\baselineskip]\node[pie-label]
{blah blah blah blah blah
blah blah blah blah blah blah
blah blah blah blah blah blah
blah blah blah blah blah blah
blah blah blah blah blah};}
}
\end{tikzpicture}
\end{figure}
\end{document}