Graphics, Figures & TablesHorizontal Line in tabbed Environment

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
teotjunk
Posts: 18
Joined: Fri Sep 19, 2008 5:28 pm

Horizontal Line in tabbed Environment

Post by teotjunk »

This is my code.

Code: Select all

\begin{tabbing}
\hline
\textbf{Alg}\=\textbf{orithm 1} Sampling from PG (1,z)\+\\
This is the error message I get.

Code: Select all

Misplaced \noalign \hline
Misplaced \noalign \hline
You can't use `\hrule' here except with leaders \hline
Missing number, treated as zero \hline
Illegal unit of measure (pt inserted) \hline
Last edited by localghost on Wed Apr 17, 2013 11:22 am, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Horizontal Line in tabbed Environment

Post by Johannes_B »

Please post a compilable working minimal example. This way it's easier for us to help you. Your case is like showing the mechanic the doorhandle of your car, asking him why the car won't drive. Please follow the link and help us to help you.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
User avatar
svend_tveskaeg
Posts: 478
Joined: Sun Jul 12, 2009 5:31 am

Re: horizontal line in tabbing

Post by svend_tveskaeg »

Furthermore, just above the editing window (see attached screenshot), there are several bottons to help editing the post.

For example, when you have code, highlight it by pressing the "Code" botton.
Attachments
Editing window.
Editing window.
editing-window.jpg (66.23 KiB) Viewed 13689 times
``In the game of chess, you can never let your adversary see your pieces.''
-- Zapp Brannigan, Futurama (season 1, episode 4)
teotjunk
Posts: 18
Joined: Fri Sep 19, 2008 5:28 pm

Horizontal Line in tabbed Environment

Post by teotjunk »

Code: Select all

\documentclass[12pt]{report}

%\usepackage

\begin{document}


\begin{tabbing}\\
\hline
\textbf{Alg}\=\textbf{orithm 1} Sampling from PG (1,z)\+\\
  \textbf{Input}: $z$ a positive real number\\
\end{tabbing}
\end{document}





User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Horizontal Line in tabbed Environment

Post by cgnieder »

\hline is not meant for use in the {tabbing} environment. Internally it uses \noalign which cannot be used here and which is why you get the error. You could instead use a standard \rule:

Code: Select all

\documentclass[12pt]{report}

\begin{document}

\begin{tabbing}
\rule{\linewidth}{\arrayrulewidth}\\
\textbf{Alg}\=\textbf{orithm 1} Sampling from $PG(1,z)$ \+ \\
  \textbf{Input}: $z$ a positive real number\\
\end{tabbing}

\end{document}
You could also define a custom command \tabrule for this, maybe with an optional argument for the width:

Code: Select all

\documentclass{article}

\newcommand*\tabrule[1][]{%
  \if\relax\detokenize{#1}\relax
    \rule{\linewidth}{\arrayrulewidth}%
  \else
    \rule{#1}{\arrayrulewidth}%
  \fi
}

\begin{document}

\begin{tabbing}
 \tabrule\\
 \textbf{Alg}\=\textbf{orithm 1} Sampling from $PG(1,z)$ \+ \\
   \textbf{Input}: $z$ a positive real number\\
\end{tabbing}

\end{document}
tabbing.png
tabbing.png (7 KiB) Viewed 13665 times
Regards
site moderator & package author
Post Reply