Adding tabs or creating my own command
If I understand correctly, you are looking for something like this:
\documentclass{article}
\newcommand{\itab}[1]{\hspace{0em}\rlap{#1}}
\newcommand{\tab}[1]{\hspace{.2\textwidth}\rlap{#1}}
\begin{document}
\begin{enumerate}
\item \itab{Format:} \tab{$math$ formula}
\tab{is} \tab{(the real number)}
\item \itab{Example:} \tab{$\pi$}
\tab{is (first digits)} \tab{3.141593}
\item \itab{Ome more:} \tab{$log_{10}(\pi)$}
\tab{is} \tab{1.14473}
\end{enumerate}
\end{document}
Update
A simpler approach is put the text in a \makebox
so we need only one command. In the example, when the text is wider than 25% of the line width, the text turns red (for demostration purposes) and the length of the \makebox
is doubled automatically:
\documentclass{article}
\usepackage{ifthen,xcolor}
\newlength{\tabcont}
\newcommand{\tab}[1]{%
\settowidth{\tabcont}{#1}%
\ifthenelse{\lengthtest{\tabcont < .25\linewidth}}%
{\makebox[.25\linewidth][l]{#1}\ignorespaces}%
{\makebox[.5\linewidth][l]{\color{red} #1}\ignorespaces}%
}%
\begin{document}
\begin{enumerate}
\item \tab{Format:}
\tab{$math$ formula}
\tab{is}
\tab{(the real number)}
\item \tab{Example:}
\tab{$\pi$}
\tab{is (first digits)}
\tab{3.141593}
\item \tab{Example:}
\tab{$\pi$}
\tab{is (more digits)}
\tab{3.141592653589793238}
\item \tab{One more example:}
\tab{$log_{10}(\pi)$}
\tab{is}
\tab{1.14473}
\end{enumerate}
\end{document}
Update
But there is no need to reinvent the wheel! It could be worth look the tabto package:
\documentclass{article}
\usepackage{tabto}
\begin{document}
\begin{enumerate}
\NumTabs{6}
\item Format:
\tab{$math$ formula}
\tab{is}
\tab{(the real number)}
\item Example:
\tab{$\pi$}
\tab{is (first digits)}
\tab{3.141593}
\item Example:
\tab{$\pi$}
\tab{is (more digits)}
\tab{3.141592653589793238}
\item One more example:
\tab{$log_{10}(\pi)$}
\tab{is}
\tab{1.14473}
\end{enumerate}
\end{document}
The result is the same as above (without color).
Here is an option that mimics Heiko's answer in I want to indent the next line by an exactly specified position:
\documentclass{article}
%\usepackage{showframe}% http://ctan.org/pkg/showframe
\usepackage[savepos]{zref}% http://ctan.org/pkg/zref
\makeatletter
% \zsaveposx is defined since 2011/12/05 v2.23 of zref-savepos
\@ifundefined{zsaveposx}{\let\zsaveposx\zsavepos}{}
\newcounter{hposcnt}
\renewcommand*{\thehposcnt}{hpos\number\value{hposcnt}}
\newcommand*{\tab}[2]{% \tab{<len>}{<stuff>}
\stepcounter{hposcnt}%
\zsaveposx{\thehposcnt}%
\zref@refused{\thehposcnt}%
\kern\dimexpr-\zposx{\thehposcnt}sp+1in+\oddsidemargin\relax%
\rlap{\kern#1\relax#2}%
\kern\dimexpr-1in-\oddsidemargin+\zposx{\thehposcnt}sp\relax%
}
\makeatother
\setlength{\parindent}{0pt}% Just for this example
\begin{document}
\makebox[5em][l]{\texttt{5em}\hrulefill}\par
\makebox[25ex][l]{\texttt{25ex}\hrulefill} \par
\makebox[\linewidth][l]{\texttt{\string\linewidth}\hrulefill} \par
Text1 \tab{5em}{Text2} \tab{25ex}{Text3} \tab{\linewidth}{Text4}
\end{document}
It allows you to specify a tab position relative to the left margin of the text block using \tab{<len>}{<stuff>}
. Positioning is managed via zref
's savepos
module to mark the PDF location/length (in s
caled p
oints) and then perform the horizontal jumping around via \kern
ing.
In the image provided, the horizontal tab stops are identified via markers to accentuate the positioning.