远方不远
远方不远
这家伙很懒,什么也没写!

注册于 1年前

回答
16
文章
0
关注者
0

我是这么理解的:三个 TikZ 环境相当于三个水平盒子,由于长度问题不能放在同一行,所以该自定义命令总体是按照段落模式确定基线的,所以产生了你说的垂直空白。

以下给出一种思路以参考:mwe-1.png

以下为代码:

\documentclass[UTF8]{ctexart}
\usepackage{tikz}
    \usetikzlibrary{calc}
\usepackage{geometry}
    \geometry{showframe,margin=.5cm,papersize={16cm,20cm}}
\newcommand\nicetitleA[1]{\vskip1.5ex
    \centerline{\tikz
       {\node (#1) at (.5\textwidth,0) [align=center] {\Huge\bfseries #1};
        \draw [dashed,red,thick]  
            (.1\textwidth,0 |- #1.north west) -- 
            (#1.north east -| .9\textwidth,0);
        \draw [dashed,cyan,thick] 
            (.1\textwidth,0 |- #1.south west) -- 
            (#1.south east -| .9\textwidth,0);
       }%
    }
} 
\newcommand\nicetitleB[1]{\vskip1.5ex
    \centerline{\tikz
       {\node (#1) at (.5\textwidth,0) 
            [text width=.65\textwidth,align=center] {\Huge\bfseries #1};
        \draw [dashed,red,thick]  
            ($(.1\textwidth,0 |- #1.north west)+(0,.5cm)$) -- 
            ($(#1.north east -| .9\textwidth,0)+(0,.5cm)$);
        \draw [dashed,cyan,thick] 
            ($(.1\textwidth,0 |- #1.south west)+(0,-.5cm)$) -- 
            ($(#1.south east -| .9\textwidth,0)+(0,-.5cm)$);
       }%
    }
} 
\newcommand\zhlipsumX{劳仑衣普桑,认至将指点效则机,最你更枝。想极整月正进好志次回总般,段然取向使张规军证回,世市总李率英茄持伴。用阶千样响领交出,器程办管据家元写,名其直金团。化达书据始价算每百青,金低给天济办作照明,取路豆学丽适市确。}
\begin{document}
\zhlipsumX

\nicetitleA{去吧,皮卡丘!}

\zhlipsumX

\nicetitleA{回来吧,皮卡丘!}

\zhlipsumX

\nicetitleB{该你上场了,妙蛙种子!}

\zhlipsumX

\nicetitleB{Come back soon!我亲爱的妙蛙种子!}

\zhlipsumX
\end{document}

发布
问题