Graphics, Figures & Tables[tabularx] Cell width/height & horizontal/vertical justification

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
noah
Posts: 4
Joined: Mon Oct 02, 2023 3:21 am

[tabularx] Cell width/height & horizontal/vertical justification

Post by noah »

Hello,

Following up my previous post on table environments/packages. Here is a MWE of a table I'd like to create (the current output is not my intention).

Code: Select all

%%% Preamble %%%
\documentclass[12pt]{article}

% Element packages
\usepackage{tabularx} % for tables
\renewcommand\tabularxcolumn[1]{m{#1}} % for vertical centering text in X column
\usepackage{booktabs,adjustbox}
\usepackage{array, multirow}
\setlength{\tabcolsep}{18 pt}
\renewcommand{\arraystretch}{1.5}

%%% Body %%%

\begin{document}

\begin{table}[h!]
    \begin{tabularx}{\textwidth} { 
  | >{\raggedright\arraybackslash}X  
  | >{\raggedright\arraybackslash}X | }

    \hline
    \textbf{Name of Property} & \textbf{Definition} \\
    \hline
    \textbf{Addition, Subtraction, Multiplication, Division \linebreak Property of Equality}
    &
    \
    \vspace{1in} \\
    \hline
    \textbf{Simplify}
    &
    \
    \vspace{1in}  \\
    \hline

\end{tabularx}
\end{table}

\end{document}
I'm sorry I can't figure out how to post the special code window or upload a screenshot on this forum. I've attached the output below. I would like the text in the first column to be vertically justified in the center. I would also like to specify the width of the first column. I am creating the blank cell as this is a worksheet to be filled out by students. I am achieving this with a \vspace{1in} now, but I would prefer to just specify a row height. Am I doing this in a foolish way? I'd appreciate help with this particular problem, but I would love a more general solution/explanation of tables (See my first post).

Thank you in advance!
Noah
Attachments
Screenshot of output.
Screenshot of output.
Screenshot 2023-10-16 4.22.24 PM.png (11.52 KiB) Viewed 11688 times
Last edited by Stefan Kottwitz on Sat Oct 21, 2023 2:47 pm, edited 1 time in total.
Reason: code marked

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
coachbennett1981
Posts: 269
Joined: Fri Feb 05, 2010 10:15 pm

[tabularx] Cell width/height & horizontal/vertical justification

Post by coachbennett1981 »

Try adding

Code: Select all

\setlength{\arrayrulewidth}{0.5mm}
to your preamble. This will adjust the thickness of the table.

In order to adjust the height from where the text starts, you can add

Code: Select all

{\setlength{\extrarowheight}{10pt}
Right before the beginning table and adjust accordingly.

You can also add the code

Code: Select all

\setlength{\tabcolsep}{5pt} 
to the preamble to adjust where the text starts (compared to the table's border.


Hopefully this helps
Post Reply