TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

enter image description here

Look at the two blue coloured rules with a colour gradient. This is what I'm looking for. Thank You.

share|improve this question

You can control the distance between the gradients and text changing the values 1em for example. Also, the height for rectangle could be changed 1.5em.

\documentclass{article}
\usepackage{lipsum}%dummy text only
\usepackage{tikz}
\usetikzlibrary{fadings}
\newcommand{\gradient}[1]{\noindent%
    \begin{tikzpicture}
    \fill[cyan,path fading=east] (0,1em) rectangle (\linewidth,1.5em);
    \node at (.5\linewidth,0) {\bfseries #1};
    \fill[cyan,path fading=west] (0,-1em) rectangle (\linewidth,-1.5em);
    \end{tikzpicture}%
}

\begin{document}
\lipsum[1]
\gradient{Thermodynamics}
\lipsum[2]
\end{document}

enter image description here

share|improve this answer

Adapting Sigur's answer to just give a command for the rule itself without the rest of the header, you might try

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{fadings}
\newcommand{\tikzrule}[3][]{\tikz{\fill[#1] (0,0) rectangle (#2,#3);}}

\begin{document}
{\centering
\tikzrule[cyan, path fading=east]{\textwidth}{1em}\\[.5em]
\textbf{Thermodynamics}\\[.5em]
\tikzrule[cyan, path fading=west]{\textwidth}{1em}
}

\noindent
\tikzrule{.9\textwidth}{3pt}\\
\rule{.9\textwidth}{3pt}
\end{document}

colored horizontal rules

The command \tikzrule which behaves like the built in \rule except that it takes an optional argument which is passed as a style. It is, however, a bit less robust than \rule in terms of what sorts of expressions can be used as its dimensions (e.g., \dimexpr doesn't work in \tikzrule).

Note that \tikzrule itself still works without the fadings tikzlibrary, although of course you need the library in order to produce the fading.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.