2

I created a table in LaTex using TeXstudio and cannot properly horizontally space the content within the last column.

\documentclass[12pt,a5paper,onecolumn]{book}
\usepackage{fontspec}
\usepackage{array}
\usepackage{setspace} 
\usepackage[width=5.25in, height=8.00in, left=0.50in, right=0.50in, top=0.25in, bottom=0.25in]{geometry}
\begin{document}
\begin{tabular}{ | m{2cm} | m{1.491cm} | c | c | m{1.4cm} | }
\hline
& \centering{Front} & Near-front & Central & \hspace{1.25ex}Back\\
\hline
\centering Close & \centering 〈ii〉 [i]&  &  &\\[5mm]
\hline
\centering Near-close &  & \centering 〈e〉 [ɪ] &  & \\[5mm]
\hline
\centering Mid & \centering 〈a〉 [e̞] &  &  & 〈y〉 [o̞]\\[5mm]
\hline
\centering Open-mid & \centering 〈i〉 [ɛ] & & 〈o〉 [ɞ] &\\[5mm]
\hline
\centering Open & \centering 〈ee | u〉 [ɶ] & & \centering 〈ȧ〉 [ä] &\\[10mm]
\hline
\end{tabular}
\end{document}

1

As you can see, the "Back" column is giving me issues. Without the \hspace{1.25ex} the word becomes no longer centered and applying\centering to the word returns an error.

Also, although I have m{1.4cm} for middle alignment in the last column, it seems to ignore it completely.

I am not sure what I am doing wrong since middle alignment and \centering have worked in the other columns.

  • Please make your code a compilable unit (\begin{document}, \end{document}). Avoid unnecessarily breaking example code into parts. Also, if the problem is not particularly about a font, consider making the example compilable for more people by not introducing a font dependency. – mvkorpel Jun 27 '14 at 6:46
  • 1
    @mvkorpel Ok, I think I did what you said. Hope that helps? – Manofzelego Jun 27 '14 at 7:00
  • I donot have any problem with current TeXLive 2014 – user2478 Jun 27 '14 at 7:14
  • Same here , It is compiling perfectly without any issue, check for yourself here writelatex.com/1227127ncydcc#/2959720 – Nishant Jun 27 '14 at 7:17
  • @Nishant the "<y> [o]" still is neither centered nor middle aligned. I tried to use centering before it, but that gives a compiling error: writelatex.com/1227127ncydcc – Manofzelego Jun 27 '14 at 7:21
2

I propose two variants (aesthetically slighly different), based on the makecell package, that allows for line breakss in cells and thick horizontal lines in tables, cellspace to have a greater vertical height of cell while keeping vertical centring of their contents (which the use of \arraystretch cannot do) and tabularx to have the 4 last cells of equal width.

There were warnings from the geometry package, so I simplified options (width and height were incompatible with the margins).

\documentclass[12pt,a5paper,onecolumn]{book}

\usepackage{fontspec}
\setmainfont{Charis SIL}

\usepackage{hhline}
\usepackage{array}
\usepackage{tabularx}
\renewcommand{\tabularxcolumn}[1]{>{\centering\arraybackslash}m{#1}}
\usepackage{makecell}
\usepackage{cellspace}
\addparagraphcolumntypes{X}
\setlength\cellspacetoplimit{10pt}
\setlength\cellspacebottomlimit{10pt}
\def\thickvrule{\vrule width1pt}

\usepackage{setspace}

\usepackage[hmargin=0.50in, vmargin=0.25in]{geometry}%width=5.25in, height=8.00in,

\begin{document}

{\centering
\begin{tabularx}{\textwidth}{!{\thickvrule}Sl!{\thickvrule}*{3}{X|}X!{\thickvrule}}%{ | *{5}{S{m{2cm}}|} }%Sc
\Xcline{2-5}{1pt}
\multicolumn{1}{Sl!{\thickvrule}}{\strut} & Front & Near-front & Central & Back \\
\Xhline{1pt}
 Close & 〈ii〉 [i]& & &\\
\hline
 Near-close & & 〈e〉 [ɪ] & & \\
\hline
 Mid & 〈a〉 [e̞] & & & 〈y〉 [o̞]\\
\hline
Open-mid & 〈i〉 [ɛ] & & 〈o〉 [ɞ] &\\
\hline
 Open & \makecell{ 〈ee | u〉 \cr [ɶ]} & & 〈ȧ〉 [ä] &\\
\Xhline{1pt}
\end{tabularx}\\[1cm]

\begin{tabularx}{\textwidth}{Sl!{\thickvrule}*{3}{X|}X!{\thickvrule}}%
\multicolumn{1}{l}{} &\multicolumn{1}{c}{ Front} & \multicolumn{1}{c}{Near-front} & \multicolumn{1}{c}{Central }& \multicolumn{1}{c}{Back} \\[3pt]
\Xcline{2-5}{1pt}
 Close & 〈ii〉 [i]& & &\\
\cline{2-5}
 Near-close & & 〈e〉 [ɪ] & & \\
\cline{2-5}
 Mid & 〈a〉 [e̞] & & & 〈y〉 [o̞]\\
\cline{2-5}
Open-mid & 〈i〉 [ɛ] & & 〈o〉 [ɞ] &\\
\cline{2-5}
 Open &\makecell{〈ee | u〉 \cr [ɶ]} & & 〈ȧ〉 [ä] &\\[-1pt]
\Xcline{2-5}{1pt}
\end{tabularx}}

\end{document} 

enter image description here

|improve this answer|||||
1

Use a new column definition to get the cells centered:

\documentclass[12pt,a5paper,onecolumn]{book}
\usepackage{fontspec}
\usepackage{array}
\usepackage{ragged2e}
\newcolumntype{M}[1]{>{\Centering}m{#1}}
\usepackage{setspace} 
\usepackage[width=5.25in, height=8.00in, left=0.50in, right=0.50in, top=0.25in, bottom=0.25in]{geometry}
\begin{document}
\begin{tabular}{ | M{2cm} | M{1.491cm} | c | c | M{1.4cm} | @{}M{0pt} @{}}
\hline
& Front & Near-front & Central & Back\\
\hline
Close &  〈ii〉 [i]&  &  &\\[5mm]
\hline
Near-close &  &  〈e〉 [ɪ] &  & \\[5mm]
\hline
Mid & 〈a〉 [e̞] &  &  & 〈y〉 [o̞]\\[5mm]
\hline
Open-mid &  〈i〉 [ɛ] & & 〈o〉 [ɞ] &\\[5mm]
\hline
Open &  〈ee | u〉 [ɶ] & & 〈ȧ〉 [ä] &\\[10mm]
\hline
\end{tabular}
\end{document}

enter image description here

|improve this answer|||||
  • That seems a lot cleaner, but the "〈y〉 [o̞]" is not middle aligned (although shouldn't the m{1.4cm} make it middle aligned?) :\ – Manofzelego Jun 27 '14 at 7:44
  • that's a known issue of tabular Use an additional empty column. – user2478 Jun 27 '14 at 8:27
  • This still doesn't appear to fix the problem writelatex.com/1227127ncydcc or am I being dumb? – Manofzelego Jun 27 '14 at 8:48
  • I edited the source – user2478 Jun 27 '14 at 9:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.