Improve appearance of the table in Latex
I would rather have table with following design:
Edit:
In comparison with your table code I made the following changes:
- With use of
geometry
package and its default settings for pages' borders the width of text width is increased. With this a more space for table columns are available. Consequently, the text can be in a more beautiful form than in cells with width of 25mm. - For table environment is used
tabularx
with prescribed table width equal to text width. Using it the width of columns are automatic adopted to available text width. - Defined is
L
column types with use of\RaggedRight
fromragged2e
package. By it cell's contents are aligned to the left hyphenation of words is used when necessary. By this the cells' contents have uniform inter words space and looks nicer - For better text spacing into cells the font size
\small
is used. - For lists (
itemize
) is usedenumitem
package which enable simple customizing of lists. Withetoolbox
it is adopted for use in tables (no vertical space before and after lists, no vertical spaces between items, minimized left lists borders) - Table rules are from
booktabs
package. Also their number is reduced
to minimum (three). Rows in table are separated by vertical space determined by\addlinspace
- Coloring of rows is omitted (they also don't work nicely with rules from
booktabs
package)
\documentclass{article}
\usepackage{geometry}
\usepackage{ragged2e}
\usepackage{booktabs, tabularx}
\usepackage{enumitem}
\usepackage{etoolbox}
\AtBeginEnvironment{table}{%
\setlist[itemize]{nosep,
leftmargin=*,
before=\vspace{-0.6\baselineskip},
after=\vspace{-\baselineskip}
}
}
\hyphenation{dis-advant-ages native-script plug-ins}
\begin{document}
\begin{table}[ht]
\small
\centering
\begin{tabularx}{\linewidth}{@{} >{\RaggedRight\hsize=0.8\hsize}X
*{4}{>{\RaggedRight\hsize=1.05\hsize}X} @{}}
\toprule
& Flutter & React Native & NativeScript & Ionic \\
\midrule
Wrapper/ Container
& No & No & No & WebViews by Apache Cordova \\ \addlinespace
Other ways of accessing native APIs &
\begin{itemize}
\item Built-in classes
\item Third- party plugins
\end{itemize}
& \begin{itemize}
\item Built-in React APIs through JS
\item Native modules
\end{itemize} & Plugins developed by NativeScript team through JS
& Plugins are offered by Apache Cordova to access the native APIs of the device through WebViews \\
\addlinespace
Disadvantages & Not so many plugins in the ecosystem, so many need to be implemented
& \begin{itemize}
\item Core maintainers of modules may quit
\item Knowledge of usage of native APIs for each platform
\end{itemize} & Knowledge of usage of native APIs for each platform if plugins need to be developed
& Not direct access to native features of device because of WebViews \\
\bottomrule
\end{tabularx}
\caption{Short comparison between the four cross platform mobile development frameworks.
%\parencite{ReactNativeFramework, NativeScript, MobileChallenges2013, IonicWebsite, FlutterFramework}
}
\label{table:comparisonFrameworks}
\end{table}
\end{document}
If you not like to use wider text defined by geometry, than remove it from preamble. Table will automatic accommodate to new width. Result than will be the following:
I suggest you use a tabularx
environment, with width set to \textwidth
, ragged-right rather than full justification in all five columns, and a bespoke itemize
-like environment (called mylist
in the code below) that uses all available space.
I also wouldn't use vertical lines to separate the columns -- they're not needed, and I wouldn't use \hline
directives except at the very end of the tabularx
environment.
\documentclass{article}
\usepackage[english]{babel}
\usepackage[table]{xcolor}
\providecommand\parencite[1]{\#} % dummy definition
\usepackage{tabularx,ragged2e}
\newcolumntype{L}{>{\RaggedRight\arraybackslash\hspace{0pt}}X}
\newcolumntype{P}[1]{>{\RaggedRight}p{#1}}
\usepackage{enumitem}
\newlist{mylist}{itemize}{1} % create a bespoke itemize-like list
\setlist[mylist]{leftmargin=*,nosep,label=\textbullet}
\usepackage{etoolbox}
\BeforeBeginEnvironment{mylist}{\begin{minipage}[t]{\hsize}}
\AfterEndEnvironment{mylist}{\end{minipage}}
\hyphenation{web-views native-script} % provide additional hyphenation exceptions
\begin{document}
\begin{table}[ht]
\setlength\extrarowheight{2pt} % for a more open "look"
\rowcolors{1}{gray!25}{white}
\setlength\tabcolsep{5pt} % default: 6pt
%\centering % not needed
\begin{tabularx}{\textwidth}{ P{20mm} *{4}{L} }
\rowcolor{gray!40}
& Flutter & React Native & NativeScript & Ionic \\
%\hline
Wrapper\slash Container & No & No & No & WebViews by Apache Cordova \\
%\hline
Other ways of accessing native APIs &
\begin{mylist}
\item Built-in classes
\item Third-party plugins
\end{mylist} &
\begin{mylist}
\item Built-in React APIs through JS
\item Native modules
\end{mylist} &
Plugins developed by NativeScript team through JS &
Plugins are offered by Apache Cordova to access the native APIs of the device through WebViews \\
%\hline
Disadvantages & Not so many plugins in the ecosystem, so many need to be implemented &
\begin{mylist}
\item Core maintainers of modules may quit
\item Knowledge of usage of native APIs for each platform
\end{mylist} &
Knowledge of usage of native APIs for each platform if plugins need to be developed
& Not direct access to native features of device because of WebViews \\
\hline % <-- new
\end{tabularx}
\caption{Short comparison between the four cross platform mobile development frameworks.
\parencite{ReactNativeFramework, NativeScript, MobileChallenges2013, IonicWebsite, FlutterFramework}}
\label{table:comparisonFrameworks}
\end{table}
\end{document}
Addendum to address the follow-up query posted by @pzorba75: The etoolbox
provides the instructions \BeforeBeginEnvironment
and \AfterEndEnvironment
. These two instructions are used in the code shown above to "encase" each mylist
environment in a minipage
environment. The encasing automatically eliminates the whitespace that would otherwise be inserted before the first \item
and below the final \item
of the list. (If you don't use the minipage
approach, you'd have to eliminate the whitespace manually, as is done in Zarko's parallel answer.)
The enumitem
package actually provides the before=...
and after=...
options. Thus, one could replace
\usepackage{enumitem}
\newlist{mylist}{itemize}{1} % create a bespoke itemize-like list
\setlist[mylist]{leftmargin=*,nosep,label=\textbullet}
\usepackage{etoolbox}
\BeforeBeginEnvironment{mylist}{\begin{minipage}[t]{\hsize}}
\AfterEndEnvironment{mylist}{\end{minipage}}
with
\usepackage{enumitem}
\newlist{mylist}{itemize}{1} % create a bespoke itemize-like list
\setlist[mylist]{leftmargin=*,nosep,label=\textbullet,
before=\begin{minipage}[t]{\hsize},
after=\end{minipage}}
The output is the same as above.
For example:
\documentclass[a4paper]{article}
\usepackage[english]{babel}
\usepackage[svgnames,table]{xcolor}
\usepackage{tabularx}
\usepackage{ragged2e}
\usepackage{enumitem}
\setlist{nosep,noitemsep,topsep=0pt,leftmargin=1em}
\usepackage{biblatex}
\addbibresource{biblatex-examples.bib}
\renewcommand\tabularxcolumn[1]{>{\RaggedRight}p{#1}}
\begin{document}
\begin{table}[ht]
\rowcolors{1}{gray!25}{white}
\centering
\begin{tabularx}{\linewidth}{|>{\RaggedRight}p{12mm}|X|X|X|X|}\hline
\rowcolor{gray!40}
& Flutter & React Native & NativeScript & Ionic
\\ \hline
Wrapper/ Container & No & No & No & WebViews by Apache Cordova
\\ \hline
Other ways of accessing native APIs &
\begin{itemize}
\item Built-in classes
\item Third- party plugins
\end{itemize}
& \begin{itemize}
\item Built-in React APIs through JS
\item Native modules
\end{itemize} & Plugins developed by NativeScript team through JS
& Plugins are offered by Apache Cordova to access the native APIs of the device through WebViews
\\ \hline
Disadvantages & Not so many plugins in the ecosystem, so many need to be implemented &
\begin{itemize}
\item Core maintainers of modules may quit
\item Knowledge of usage of native APIs for each platform
\end{itemize} & Knowledge of usage of native APIs for each platform if plugins need to be
developed &
Not direct access to native features of device because of WebViews
\\\hline
\end{tabularx}
\caption{Short comparison between the four cross platform mobile development frameworks.
\parencite{ReactNativeFramework, NativeScript, MobileChallenges2013, IonicWebsite,
FlutterFramework}}
\label{table:comparisonFrameworks}
\end{table}
\end{document}