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

I have a longtable. This is my code

\usepackage{amsmath,amsxtra,amssymb,latexsym, amscd,amsthm}
\renewcommand{\Solnlabel}[1]{{\bf  Answer #1}.}


\newcommand\diem[1]{ & \hfil \textbf{#1} \\ \hline}
\newcommand\tongdiem[1]{\dotfill [\textbf{#1} points]}
%\newcommand\tongdiem[1]{\fill [\textbf{#1} điểm]}

(2 points) Find the domain of definition of the function \begin{equation*}
y = \sqrt{x^2 - 3x + 2} + \dfrac{1}{x + 4}.
First \diem{1}

This is 



(2 points) Solve the equation \begin{equation*}
\sqrt{x + 1} + \sqrt{x + 2}-\sqrt{x + 3} =5.
First \diem{1}




\noindent \hrulefill



I want the out put has the form. Please help me. enter image description here

share|improve this question
don't use \noindent before longtable: it just causes a blank white line to be inserted before the table along with spurious parskip vertical space, and if you are unlucky, a bad page break. – David Carlisle Nov 24 '12 at 11:31
up vote 5 down vote accepted

You can get the both the sides aligned using:


enter image description here

This computes the required width of the right column so as to fill it.

If you just want to alignit on the right you can use the optional paraamter of longtable to specify that the table is to be right aligned:


enter image description here


  • The [showframe] option to the geometry package was used so that we could see the page margins. was used just to show the page margins.
  • Another option would be to use the tabularx package which allows for X column types that can expand to fill the specified width.
  • Further more you should have a look at the booktabs package for more professional looking tables.
  • As Marco Daniel commented, you should also have a look at the the ltxtable package which provides the functionality of longtable and tabularx together inside a longtable environment.
share|improve this answer
Small hint: The optional argument of the environment longtable specify the horizontal alignment. Allowed parameter are: c, l and r. And I think ltxtable should be mentioned here. – Marco Daniel Nov 24 '12 at 7:32
@MarcoDaniel: Thanks. I did not read that as an option, but you are correct the question does not specify whether the alinement is to just be on the right, or on both sides, which is what I had interpreted. – Peter Grill Nov 24 '12 at 8:21
just a small remark: in the argument [r] no spaces are allowed for proper function, like <strike>[ r ]</strike> – escalator May 7 '14 at 11:07

Your Answer


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.