Cyrus
Cyrus

Reputation: 65

How to fix a specific width for tables keep right instead of left from latex?

I have a table need to write in latex, then I need to use the following code to make a table.

\begin{table}[]
\begin{tabular}{|l|r|}
\hline
\textbf{Item}         & \textbf{Amount} \\ \hline
User Account          & 15,763          \\ \hline
Original Post         & 56,797          \\ \hline
Post Reply            & 1,515,618       \\ \hline
Post (Original+Reply) & 1,572,415       \\ \hline
Adopted Post          & 88,240          \\ \hline
\end{tabular}
\end{table}

However, it cannot set a specific width. When I want to write \begin{tabular}{|l{3.8}|r{3.8}|}, it does not work.

If I use p{3.8cm}, it does work. However, it does not keep right but left.

I want to make a specific width from the table and set it to keep right instead of the left.

Can anyone help me? Thanks!!

Upvotes: 0

Views: 272

Answers (1)

\documentclass{article}

\usepackage{array}

\begin{document}

\begin{table}[]
\begin{tabular}{|l|>{\raggedleft\arraybackslash}p{3.8cm}|}
\hline
\textbf{Item}         & \textbf{Amount} \\ \hline
User Account          & 15,763          \\ \hline
Original Post         & 56,797          \\ \hline
Post Reply            & 1,515,618       \\ \hline
Post (Original+Reply) & 1,572,415       \\ \hline
Adopted Post          & 88,240          \\ \hline
\end{tabular}
\end{table}


\end{document}

Upvotes: 1

Related Questions