TransWikia.com

Left align table column with fixed length

TeX - LaTeX Asked by Ruben Post on March 6, 2021

I’m trying to create two tables: the first column should align left with .25 linewidth and the second column should align left with .69 linewidth while wrapping if the text becomes too long. The actual width of the column is irrelevant as long as they are similar.

The following code does all I want except for aligning left:

begin{table}[ht]
begin{tabular}{p{0.25linewidth} p{0.69linewidth}}
hline
rowcolor[HTML]{EFEFEF}
Category                    & Description                                                                                                hline
Instance duration           & Limits the duration in which a control-flow rule instance must hold.                                       hline
Delay between instances     & Limits the delay between two subsequent instances of a control-flow rule                                   hline
Validity                    & Limits the time length in which an activity can be executed.                                               hline
Time restricted existence   & Limits the execution time of an activity based on some calendar.                                           hline
Repetition                  & Limits the delay between execution of two subsequent activities.                                           hline
Time dependent variability  & Limits choice of a process path among several ones with respect to temporal aspects.                       hline
Overlap                     & Limits the start and completion of an activity w.r.t. the start and the completion of another activity.    hline
end{tabular}
caption{label{tab:temporal}Categorization of temporal compliance rules cite{ramezani2017understanding, caron2013comprehensive}.}
end{table}

How can I align the first column to the left?

2 Answers

You are asking for something like that?

tt

documentclass[12pt,a4paper]{article}

usepackage[table]{xcolor}

begin{document}
    begin{table}[ht]
        begin{tabular}{>{raggedright}p{0.25linewidth} p{0.69linewidth}}
            hline
            rowcolor[HTML]{EFEFEF}
            Category                    & Description                                                                                                hline
            Instance duration           & Limits the duration in which a control-flow rule instance must hold.                                       hline
            Delay between instances     & Limits the delay between two subsequent instances of a control-flow rule                                   hline
            Validity                    & Limits the time length in which an activity can be executed.                                               hline
            Time restricted existence   & Limits the execution time of an activity based on some calendar.                                           hline
            Repetition                  & Limits the delay between execution of two subsequent activities.                                           hline
            Time dependent variability  & Limits choice of a process path among several ones with respect to temporal aspects.                       hline
            Overlap                     & Limits the start and completion of an activity w.r.t. the start and the completion of another activity.    hline
        end{tabular}
        caption{label{tab:temporal}Categorization of temporal compliance rules cite{ramezani2017understanding, caron2013comprehensive}.}
    end{table} 
    
end{document}

Correct answer by Simon Dispa on March 6, 2021

In addition to forcing the cell -contents to be typeset ragged-right rather than fully justfied, you may also want to (a) switch to a tabularx environment to maximize the line length available to the second columns and (b) give the table a more open "look" by replacing most instances of hline with addlinespace, a directive provided by the booktabs package.

enter image description here

documentclass{article} 
usepackage[table]{xcolor}
usepackage{ragged2e} % for 'RaggedRight' macro
usepackage{tabularx} % for 'tabularx' env. and 'X' column type
usepackage{booktabs} % for addlinespace and bottomrule macros
begin{document}
begin{table}[ht]
begin{tabularx}{textwidth}{ >{RaggedRight}p{0.25linewidth} >{RaggedRight}X }
hline
rowcolor[HTML]{EFEFEF}
Category                    & Description  hline addlinespace
Instance duration           & Limits the duration in which a control-flow rule instance must hold.  addlinespace
Delay between instances     & Limits the delay between two subsequent instances of a control-flow rule  addlinespace
Validity                    & Limits the time length in which an activity can be executed.  addlinespace
Time restricted existence   & Limits the execution time of an activity based on some calendar.  addlinespace
Repetition                  & Limits the delay between execution of two subsequent activities.  addlinespace
Time dependent variability  & Limits choice of a process path among several ones with respect to temporal aspects.  addlinespace
Overlap                     & Limits the start and completion of an activity w.r.t. the start and the completion of another activity.    
bottomrule
end{tabularx}
caption{Categorization of temporal compliance rules cite{ramezani2017understanding, caron2013comprehensive}.}
label{tab:temporal}
end{table}
end{document}

Answered by Mico on March 6, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP