1

I was using the technique described here but I got the odd result show in the picture (near the cursor).

Any thoughts why and how it can be solved?

enter image description here

\documentclass[12pt,openright,twoside]{article}

\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{times}
\usepackage[table]{xcolor}
\usepackage{tabularx}

\usepackage{footnote}
\makesavenoteenv{tabular}
\makesavenoteenv{table}

\usepackage{geometry}
\geometry{margin=0.8in}


%for notes
\usepackage[show]{chato-notes}

\definecolor{light-gray}{gray}{0.65}
\definecolor{very-light-gray}{gray}{0.80}

\newcolumntype{b}{X}
\newcolumntype{s}{>{\hsize=.2\hsize}X}
\newcolumntype{v}{>{\hsize=.05\hsize}X}

\begin{document}
\date{}
\maketitle

\begin{table}[htbp]
    \centering
    %\begin{tabularx}{\textwidth}{| X | X | X |}
    \begin{tabularx}{\textwidth}{|b|s|s|}
        \hline
        Alpha     & Beta     & Gamma     \\ \hline
        0         & 2        & 4         \\ \hline
        1         & 3        & 5         \\ \hline
    \end{tabularx}
\end{table}

\end{document}
Camandros
  • 113
  • 1
    see the tabularx manual you have 3 X columns so the widths have to add up to 3\hsize and you have 1+.2+.2= 1.4 which will break tabularx completely and make it unable to find any sensible widths – David Carlisle Jan 26 '17 at 20:12

3 Answers3

3

I guess you want three X columns, the last two having width equal to 1/5 the width of the first column. In this case the ratios α and β, somewhat like barycentric coordinates, must satisfy the equations α = 5β, α + 2β =3, i.e. α=15/7, β=3/7. An approximation is 2.15 and 0.425 respectively.

So I think you're after this:

\documentclass[12pt,openright,twoside]{article}

\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{mathptmx}
\usepackage[table]{xcolor}
\usepackage{tabularx}

\usepackage{geometry}
\geometry{margin=0.8in,  showframe}

\begin{document}

\begin{table}[htbp]
    \centering
 \begin{tabularx}{\textwidth}{|>{\hsize=2.15\hsize}X|>{\hsize=.425\hsize}X|>{\hsize=.425\hsize}X|}
        \hline
        Alpha & Beta & Gamma \\ \hline
        0 & 2 & 4 \\ \hline
        1 & 3 & 5 \\ \hline
\end{tabularx}

\end{table}

\end{document}

enter image description here

Bernard
  • 271,350
2

As @DavidCarlisle already mentioned, the sum of the widths should add up to 3X because you have 3 columns. So, if you need column 3, e.g., to be 0.08\textwidth you should set \hsize=3*0.08 approx 0.25\hsize in the specification for \newcolumntype{v}.

My advice, however, is to simplify the problem by just using the p column. See the two options below:

%\newcolumntype{b}{>{\hsize=2.15\hsize}X}
%\newcolumntype{s}{>{\hsize=0.6\hsize}X}
%\newcolumntype{v}{>{\hsize=0.25\hsize}X}

\begin{table}[htbp]
    \centering
    %\begin{tabularx}{\textwidth}{|b|s|v|}  % <= This solution
    \begin{tabularx}{\textwidth}{|X|p{.2\textwidth}|p{.08\textwidth}|} % <= Or this
        \hline
        Alpha     & Beta     & Gamma     \\ \hline
        0         & 2        & 4         \\ \hline
        1         & 3        & 5         \\ \hline
    \end{tabularx}
\end{table}

enter image description here

AboAmmar
  • 46,352
  • 4
  • 58
  • 127
0

Since you know the proportions of your columns, that is, the first column should be four times the other two, you can simply do some math, which you need to do with tabularx anyhow.

\documentclass{article}
\usepackage{array}

% The available space is \textwidth
% minus twice the number of columns \tabcolsep spaces
% minus one more than the number of columns \arrayrulewidth
%
% The first two arguments to P are numerator and denominator
% and the third argument is the number of columns

% In this case the fractions are 4/6, 1/6 and 1/6
\newcolumntype{P}[3]{%
  p{#1\dimexpr(
        \textwidth-
        \tabcolsep*\numexpr2*#3\relax-
        \arrayrulewidth*\numexpr#3+1\relax
      )/#2%
  }%
}

\begin{document}

\noindent
X\dotfill X

\noindent
\begin{tabular}{|P{4}{6}{3}|P{1}{6}{3}|P{1}{6}{3}|}
\hline
Alpha     & Beta     & Gamma     \\ \hline
0         & 2        & 4         \\ \hline
1         & 3        & 5         \\ \hline
\end{tabular}

\end{document} 

So you just need to divide 1 into parts proportional to 4, 1 and 1, so 4/6, 1/6 and 1/6.

enter image description here

egreg
  • 1,121,712