断开的线、间距和大小调整目录树

断开的线、间距和大小调整目录树

我正在dirtree制作一棵树,但我注意到在某些元素末尾的括号之间添加数字会导致树的线条断开。有什么办法可以让它们保持连接吗?有没有办法在文本和其下方的垂直线之间创建一个垂直空间(可能是 1 毫米)?最后,有没有办法缩小它(尝试更改字体大小但树的大小保持不变)?

树

这是代码:

\renewcommand{\DTstyle}{\textrm\expandafter\raisebox{-0.7ex}}
\DTsetlength{1em}{1em}{0.2em}{0.4pt}{0.4pt}

\dirtree{% 
.1 Romance.
.2 Eastern (4).
.2 Italo-Western.
.3 Italo-Dalmatian (5).
.3 Western.
.4 Gallo-Iberian.
.5 Gallo-Romance.
.6 Gallo-Italian (6).
.6 Gallo-Rhaetian.
.7 Oïl.
.8 French (5).
.8 Southeastern (1).
.7 Rhaetian (3).
.5 Ibero-Romance.
.6 East Iberian (1).
.6 Oc (2).
.6 West Iberian.
.7 Asturo-Leonese (2).
.7 Castilian (4).
.7 Portuguese-Galician (4).
.4 Pyrenean-Mozarabic.
.5 Pyrenean (1).
.2 Southern.
.3 Corsican (1).
.3 Sardinian (4).
}

答案1

我在包装上添加了一个补丁dirtree,将短水平线上移,连接线条,并在文本和下面的垂直线之间添加一个小的空白区域。

(1)通过设置来控制树的文本行相对于短水平线的位移\upBranch

(2)用于\tolineSpace在文本行下方添加空白区域(最多有限制,取决于树的字体大小)

(3)通过更改 来扩展树的大小\DTbaselineskip。使用此补丁,在保持所有线连接的情况下,树的最小大小取决于字体大小。

对于\footnotesize为 12pt,对于\large为 18pt,等等。

z2

缩放树,测试不同的树字体大小并更改基线跳过

是

% !TeX TS-program = pdflatex    

\documentclass[12pt,a4paper]{article}

\usepackage{dirtree}
    
%% *****************************************************************
\newlength{\upBranch} % shift up the text  lines <<<<
\setlength{\upBranch}{0.7ex} % 

\newlength{\tolineSpace} % blank space bellow text  lines  <<<
\setlength{\tolineSpace}{1mm}% 

\usepackage{xpatch} % needed <<<<<<<<
\makeatletter

\xpatchcmd{\dirtree} % root
{\vbox{\@nameuse{DT@body@1}}}
{\raisebox{-\tolineSpace}{\vbox{\@nameuse{DT@body@1}}}}
{}{}    

\xpatchcmd{\dirtree} % below space
{\advance\dimen\z@ by-\@nameuse{DT@lastlevel@\the\DT@countiv}\relax}
{\advance\dimen\z@ by-\tolineSpace \advance\dimen\z@ by-\@nameuse{DT@lastlevel@\the\DT@countiv}\relax}
{}{}
    
\xpatchcmd{\dirtree}% shift up the text  lines
{\kern\DT@sep\box\z@\endgraf}
{\kern\DT@sep\raisebox{-\upBranch}{\box\z@}\endgraf}
{}{}    

\makeatother
%% *****************************************************************

\begin{document}    

\DTsetlength{1em}{1em}{0em}{0.4pt}{0.4pt}       

%\setlength{\DTbaselineskip}{12pt}  % minimum size for \footnotesize 
%\renewcommand{\DTstyle}{\rmfamily\footnotesize} 
    
%\setlength{\DTbaselineskip}{16pt}  %minimum size for \normalsize
%\renewcommand{\DTstyle}{\rmfamily\normalsize} 

\setlength{\DTbaselineskip}{18pt} %minimum size for  \large
\renewcommand{\DTstyle}{\rmfamily\large}    %

%\setlength{\DTbaselineskip}{22pt} %minimum size for  \Large
%\renewcommand{\DTstyle}{\rmfamily\Large}   %   
        
\textbf{Tree font size =} large

\textbf{baselineskip =} \the\baselineskip
\bigskip

    
    \dirtree{% 
        .1 Romance.
        .2 Eastern (4).
        .2 Italo-Western.
        .3 Italo-Dalmatian (5).
        .3 Western.
        .4 Gallo-Iberian.
        .5 Gallo-Romance.
        .6 Gallo-Italian (6).
        .6 Gallo-Rhaetian.
        .7 Oïl.
        .8 French (5).
        .8 Southeastern (1).
        .7 Rhaetian (3).
        .5 Ibero-Romance.
        .6 East Iberian (1).
        .6 Oc (2).
        .6 West Iberian.
        .7 Asturo-Leonese (2).
        .7 Castilian (4).
        .7 Portuguese-Galician (4).
        .4 Pyrenean-Mozarabic.
        .5 Pyrenean (1).
        .2 Southern.
        .3 Corsican (1).
        .3 Sardinian (4).
    }       

\bigskip    
In all theoretical sciences, the paralogisms of human
reason would be falsified, as is proven in the ontological manuals.
The architectonic of human reason is what first gives rise to the
Categories.  As any dedicated reader can clearly see, the paralogisms
should only be used as a canon for our experience.

\newpage
\setlength{\baselineskip}{30pt}

\setlength{\DTbaselineskip}{12pt}  % minimum size for footnotesize 
\renewcommand{\DTstyle}{\rmfamily\footnotesize} 

\textbf{Tree font size =} footnotesize 

\textbf{baselineskip =} \the\baselineskip
\bigskip
    
\dirtree{% 
    .1 Romance.
    .2 Eastern (4).
    .2 Italo-Western.
    .3 Italo-Dalmatian (5).
    .3 Western.
    .4 Gallo-Iberian.
    .5 Gallo-Romance.
    .6 Gallo-Italian (6).
    .6 Gallo-Rhaetian.
    .7 Oïl.
    .8 French (5).
    .8 Southeastern (1).
    .7 Rhaetian (3).
    .5 Ibero-Romance.
    .6 East Iberian (1).
    .6 Oc (2).
    .6 West Iberian.
    .7 Asturo-Leonese (2).
    .7 Castilian (4).
    .7 Portuguese-Galician (4).
    .4 Pyrenean-Mozarabic.
    .5 Pyrenean (1).
    .2 Southern.
    .3 Corsican (1).
    .3 Sardinian (4).
}   
\bigskip
In all theoretical sciences, the paralogisms of human
reason would be falsified, as is proven in the ontological manuals.
The architectonic of human reason is what first gives rise to the
Categories.  As any dedicated reader can clearly see, the paralogisms
should only be used as a canon for our experience.

\end{document}

相关内容