How in the world do I place line of text EVENLY between two horizontal tikz lines?
You shouldn't use \\
to end a paragraph and the arguably simplest way is to do everything with TikZ.
\documentclass[border=5mm,varwidth=150mm]{standalone}
\usepackage{tikz}
\newcounter{bpnode}
\tikzset{every node/.append style={/utils/exec=\stepcounter{bpnode},
alias=bpnode-\number\value{bpnode}}}
\begin{document}
\begin{tikzpicture}
\node[outer sep=0pt,inner sep=0pt,text width=\textwidth,align=left] (txt)
{hello hello hello hello hello hello hello hello hello
hello hello hello hello hello hello hello hello hello
hello hello hello hello hello hello hello hello hello};
\path[draw]([yshift=1em]txt.north west)--++(\textwidth,0);
\path[draw=red]([yshift=-1em]txt.south west)--++(\textwidth,0);
%\draw (bpnode-1) -- ++ (2,0);
\typeout{\the\textwidth}
\end{tikzpicture}
\end{document}
Here is a "quick and dirty" proposal using the baseline
key.
\documentclass[border=5mm,varwidth=150mm]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[baseline=-0.6ex]
\path[draw](0,0)--(\textwidth,0);
\end{tikzpicture}\par
\noindent%
hello\par
\noindent%
\begin{tikzpicture}[baseline=-0.6ex]
\path[draw=red](0,0)--(\textwidth,0);
\end{tikzpicture}
\end{document}
This uses a \parbox
and \vfill
. The baselines are ignored in this case, since the baseline of the \parbox
is more than \baselineskip
from either above or below, so instead LaTeX adds a gap of \lineskip
(1pt). Inside the \parbox
, the \vfill
s expand to the same size. The same effect is achieved by using [c] instead of [s] and \vfill
, but I wanted to show how it was done.
\documentclass[border=5mm,varwidth=150mm]{standalone}
\usepackage{tikz}
\begin{document}
\noindent\begin{tikzpicture}
\path[draw](0,0)--(\textwidth,0);
\end{tikzpicture}\\
\parbox[c][3\baselineskip][s]{\textwidth}{\vfill
hello
\vfill}\\
\begin{tikzpicture}
\path[draw=red](0,0)--(\textwidth,0);
\end{tikzpicture}
\end{document}
This uses \raisebox
to move the text relative to the baseline. The \rule
shows where the baseline is located.
\documentclass[border=5mm,varwidth=150mm]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\path[draw](0,0)--(\textwidth,0);
\end{tikzpicture}\\
\raisebox{\dimexpr 0.5\depth-0.5\height}{Hellow}
\rule{1em}{0.5pt}
\raisebox{\dimexpr 0.5\depth-0.5\height}{pygmy}\\
\begin{tikzpicture}
\path[draw=red](0,0)--(\textwidth,0);
\end{tikzpicture}
\end{document}
Using TikZ, I would put the text in a node of the desired width, then use the node anchors do draw the lines.
\documentclass[border=5mm,varwidth=150mm]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\node(a)[minimum width=\linewidth,text width=\linewidth]{hello};
\draw(a.north west)--(a.north east);
\draw[red](a.south west)--(a.south east);
\end{tikzpicture}
\end{document}
Here's a non-TikZ answer just to show another approach.
\documentclass[border=5mm,varwidth=150mm]{standalone}
\usepackage{booktabs}
\usepackage{colortbl}
\usepackage{tabularx}
\begin{document}
\begin{tabularx}{\linewidth}{@{}l@{}}
\midrule
hello\\
\arrayrulecolor{red}\midrule
\end{tabularx}
\end{document}