发布时间:2012-08-07 08:56:18文章类别:小技巧原文地址:http://blog.sina.com.cn/s/blog_5e16f1770102ezog.html

xfill 

  • \xhrulefill: Modified dimensions for\hrulefill

  • \xrfill: Coloured horizontal rules

  • \xdotfill: 选线填充 \hrulefill

  • \xhrectanglefill: 长方形填充

示例代码如下:

\documentclass{article}
\usepackage{listings}% http://ctan.org/pkg/listings
%\usepackage{xcolor}% http://ctan.org/pkg/xcolor | Loaded by listings
\usepackage{xhfill}% http://ctan.org/pkg/xhfill

\setlength{\parindent}{0pt}% Just for this example
\newcommand{\xfill}[2][1ex]{{%
  \dimen0=#2\advance\dimen0 by #1
  \leaders\hrule height \dimen0 depth -#1\hfill%
}}
\newcommand{\xfilll}[2][1ex]{%
  \dimen0=#2\advance\dimen0 by #1%
  \leaders\hrule height \dimen0 depth -#1\hfill%
}

\begin{document}
blah\xfilll{1pt}blub
\begin{lstlisting}
blah\xfilll{1pt}blub
\end{lstlisting}
blah\xfilll{1pt}blub
\begin{lstlisting}
blah\xfilll{1pt}blub
\end{lstlisting}

blah\xfilll[0pt]{4pt}blub
\begin{lstlisting}
blah\xfilll[0pt]{4pt}blub
\end{lstlisting}

blah\xfilll[-12pt]{12pt}blub
\begin{lstlisting}
blah\xfilll[-12pt]{12pt}blub
\end{lstlisting}

blah\xrfill{1pt}[blue]blub blah\xrfill{2pt}[cyan]blub
\begin{lstlisting}
blah\xrfill{1pt}[blue]blub blah\xrfill{2pt}[cyan]blub
\end{lstlisting}

laber\xrfill[0pt]{4pt}[green]blub blub
\begin{lstlisting}
laber\xrfill[0pt]{4pt}[green]blub blub
\end{lstlisting}

blah\xrfill[-1ex]{1pt}[red]blub
\begin{lstlisting}
blah\xrfill[-1ex]{1pt}[red]blub
\end{lstlisting}

blah \xhrulefill{cyan}{1cm} blub
\begin{lstlisting}
blah \xhrulefill{cyan}{1cm} blub
\end{lstlisting}

blah \xhrectanglefill{0.5cm}{1pt} blubber
\begin{lstlisting}
blah \xhrectanglefill{0.5cm}{1pt} blubber
\end{lstlisting}

blah\xdotfill{1pt}[blue]blah\xdotfill{2pt}[red]blub
\begin{lstlisting}
blah\xdotfill{1pt}[blue]blah\xdotfill{2pt}[red]blub
\end{lstlisting}
\end{document}

选自:http://tex.stackexchange.com/questions/17124/what-is-the-rule-equivalent-for-hrule

点赞(2)

评论列表 共有 0 条评论

暂无评论
立即
投稿

微信公众账号

微信扫一扫加关注

发表
评论
返回
顶部