3

A really Latex beginner but adventurer is writing, then the question might look strange. I tried this though. I have defined the new column style but I do not know how to remove the indentation in each table cell. In this simple example how can I get rid of the gap between the "Number of terms" and the left vertical line of the table?

\documentclass{article}
\usepackage{amsmath}
\usepackage{geometry}
\usepackage{array}

\begin{document}
\parindent = 0pt
\the \parindent

\large{TEXT}

 \newcolumntype{R}[2]{
>{ \minipage[c][#1][c]{#2} }
l <
{\endminipage}
}

\begin{center}
    \begin{tabular} {|R{1cm}{.2\textwidth} R{1cm}{.2\textwidth} R{1cm}{.2\textwidth} R{1cm}{.2\textwidth}}

        Number of terms & $\sin(\dfrac{\pi}{6})$ & $\epsilon_t$ & $\epsilon_a$ \tabularnewline 
        1 &  0.52360 &  0.047198 &    \tabularnewline 
        2 & 0.49967 & 0.00065164 & 0.047880 \tabularnewline 
        3 & 0.50000 & 0.0000042652 & 0.00065590 \tabularnewline 
        4 & 0.50000 & 0.000000016261954 & 0.00000428144 \tabularnewline

    \end{tabular}
\end{center}

\end{document}

Even though I have set the \parindent to the zero value.

enter image description here

Reza
  • 319

2 Answers2

6

add @{} between | and R

\documentclass{article}
\usepackage{amsmath}
\usepackage{geometry}
\usepackage{array}

\begin{document}
\parindent = 0pt
\the \parindent

\large{TEXT}

 \newcolumntype{R}[2]{>{\minipage[c][#1][c]{#2} }
l <
{\endminipage}
}

\begin{center}
    \begin{tabular} {|@{}R{1cm}{.2\textwidth} R{1cm}{.2\textwidth} R{1cm}{.2\textwidth} R{1cm}{.2\textwidth}}

        Number of terms & $\sin(\dfrac{\pi}{6})$ & $\epsilon_t$ & $\epsilon_a$ \tabularnewline 
        1 &  0.52360 &  0.047198 &    \tabularnewline 
        2 & 0.49967 & 0.00065164 & 0.047880 \tabularnewline 
        3 & 0.50000 & 0.0000042652 & 0.00065590 \tabularnewline 
        4 & 0.50000 & 0.000000016261954 & 0.00000428144 \tabularnewline

    \end{tabular}
\end{center}

\end{document}

enter image description here

You can control how much space is inserted between the vertical line and the cell content: @{ } will insert a single space, @{\hskip<width>} will insert a specific width, say 5pt or whatever.

d-cmst
  • 23,095
  • 4
    there is no paragraph indentation in tables. what is seen in the example in the question is the \tabcolsep at the beginning of the first column. the initial @{} overrides that setting, as shown in this answer. – barbara beeton Aug 20 '16 at 21:01
  • Actually that's right. However if you set \tabcolsep zero. It applies for every cell. @barbarabeeton – Reza Aug 20 '16 at 21:27
  • @Reza -- but you don't want to apply it to every cell -- that would leave no space at all in the last row. that makes it very hard to read. – barbara beeton Aug 20 '16 at 21:47
  • @barbarabeeton No I definitely don't. It exactly messes the last row. I control the width of the cell by the second argument in the \newcolumntype{R}[2]. I can either \tabcolsept=0pt and control by argument #2, or just remove the space by @{} in the beginning of the first column. Either way the width of the cell is controlled by the definition. – Reza Aug 20 '16 at 21:58
4

Your question is not very clear to me. From your MWE I only see unnecessary complication in table design. So see, if the following solution can help you:

\documentclass{article}
\usepackage{amsmath}
\usepackage[showframe]{geometry}% option showframe serve only to show page layout, 
                                % in real aplication had to be removed
\usepackage{array}

\parindent = 0pt

\begin{document}
\the\parindent

\large{TEXT}

{\renewcommand\tabcolsep{7.5mm}
    \begin{tabular} {|@{} l l l l @{}}
Number of terms & $\sin(\dfrac{\pi}{6})$ & $\epsilon_t$ & $\epsilon_a$ \tabularnewline
1 &  0.52360 &  0.047198 &    \tabularnewline
2 & 0.49967 & 0.00065164 & 0.047880 \tabularnewline
3 & 0.50000 & 0.0000042652 & 0.00065590 \tabularnewline
4 & 0.50000 & 0.000000016261954 & 0.00000428144 \tabularnewline
    \end{tabular}
}
%\end{center}
\end{document}

It gives:

enter image description here

Zarko
  • 296,517