# How to align right this long table?

I have a longtable. This is my code

\documentclass[12pt,a4paper]{article}
\usepackage{amsmath,amsxtra,amssymb,latexsym, amscd,amsthm}
\usepackage{indentfirst}
\usepackage[mathscr]{eucal}
\usepackage{graphicx}
\usepackage{makecell}
\usepackage{longtable}
\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}
\theoremstyle{definition}
\newtheorem{cauhoi}{Quetion}
\Newassociation{ans}{Soln}{hint}

\newenvironment{point}{%
\par\noindent
\begin{longtable}[t]{|p{14cm}|p{1.2cm}|}

\hline
}{%
\end{longtable}
}
\newcommand\diem[1]{ & \hfil \textbf{#1} \\ \hline}
\newcommand\tongdiem[1]{\dotfill [\textbf{#1} points]}
%\newcommand\tongdiem[1]{\fill [\textbf{#1} điểm]}
\usepackage{mathpazo}
\begin{document}
\setlength{\baselineskip}{16truept}
\Opensolutionfile{hint}[ans]

\thispagestyle{empty}
\begin{center}
QUESTIONS
\end{center}
\begin{cauhoi}%1
(2 points) Find the domain of definition of the function \begin{equation*}
y = \sqrt{x^2 - 3x + 2} + \dfrac{1}{x + 4}.
\end{equation*}
\begin{ans}\tongdiem{2.5}
\begin{point}
First \diem{1}

This is
\diem{1.0}

Second
\diem{0.5}

\end{point}
\end{ans}
\end{cauhoi}

\begin{cauhoi}%2
(2 points) Solve the equation \begin{equation*}
\sqrt{x + 1} + \sqrt{x + 2}-\sqrt{x + 3} =5.
\end{equation*}
\begin{ans}\tongdiem{2.5}
\begin{point}
First \diem{1}

Second
\diem{1.0}

Thirt
\diem{0.5}

\end{point}
\end{ans}
\end{cauhoi}

\vfill
\noindent \hrulefill

\Closesolutionfile{hint}
\newpage
\begin{center}
\end{center}

\end{document}


I want the out put has the form. Please help me.

-
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

You can get the both the sides aligned using:

\begin{longtable}[t]{|p{14cm}|p{\dimexpr\linewidth-14cm-3\tabcolsep-2\arrayrulewidth\relax}@{}|}


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:

\begin{longtable}[r]{|p{14cm}|p{1.2cm}|}


## Notes:

-
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