0

How can I change this table style:

% !TeX spellcheck = de_DE
\documentclass[a4paper,12pt]{article}[12pt] % Prepara un documento per carta A4, con un bel font grande

\usepackage[italian]{babel} % Adatta LaTeX alle convenzioni tipografiche italiane,
% e ridefinisce alcuni titoli in italiano, come "Capitolo" al posto di "Chapter",
% se il vostro documento è in italiano
\usepackage[T1]{fontenc} % Riga da togliere se si compila con PDFLaTeX
\usepackage[utf8]{inputenc} % Consente l'uso caratteri accentati italiani

\usepackage{anysize}
\usepackage{graphicx}
\usepackage{float}
\usepackage{etoolbox}
\usepackage{amsbsy}
\usepackage{amsmath}
\usepackage{pbox}
\usepackage{fancyhdr}
\usepackage{cancel}
\usepackage{tabularx} %pacchetto tabelle tia
\usepackage{booktabs} %pacchetto tabelle tia
\usepackage{multirow} %pacchetto tabelle luca
\usepackage{longtable} %tabelle lunghe
\usepackage{natbib} %PROVA bibliografia
%\usepackage{cite} %BibTeX
\usepackage{tikz}  

\usepackage{subfig}                         % sottofigure, sottotabelle

\usepackage{xcolor}

%\usepackage{package}

\usepackage{amsmath} %posso scrivere caratteri speciali
\usepackage{amssymb} %anche questoo per caratteri speciali come \Box
\usepackage{mathrsfs} 

\usepackage{textcomp} %gradi con latex

\linespread{1.5}                    %spessore interlinea (default=1, MM1 = s1.4)

\frenchspacing 

\newcommand{\abs}[1]{\lvert#1\rvert}

\usepackage{floatflt,epsfig}

\usepackage{multicol}

%\usepackage[a4paper,top=1.5cm,bottom=1.5cm,left=1.5cm,right=1.5cm]{geometry}

\usepackage[a4paper,top=1.0cm,bottom=1.0cm,left=1.0cm,right=1.0cm]{geometry}

%   \renewcommand{\rmdefault}{phv}
%   %\usepackage{mathpple}
%   %\usepackage{palatino}
%   
%   \usepackage{lxfonts}
%%   
%%   \usepackage{multicol}

\newcommand\yellowbigsqcup[1][\displaystyle]{%
  \fboxrule0pt
  \ifx#1\textstyle\fboxsep-0.6pt\else\fboxsep-1.25pt\fi
  \mathrel{\fcolorbox{white}{yellow}{$#1\bigsqcup$}}}

\begin{document}

% Table generated by Excel2LaTeX from sheet 'Foglio1'   

\end{document}

enter image description here

in a table style like this one?

enter image description here

  • Please clarify what you mean by "change the table style". Are you trying the make entire header row yellow? Are the four columns all supposed to be equally wide? Or is it something else? – Mico Nov 15 '17 at 23:36
  • @Mico I've added another pic. In my table i can see all the boundary of the colomns and the raws. – ryuk Nov 15 '17 at 23:41
  • 2
    where is code of table? for table the most of package in preamble is not needed. also it is sufficient to load any package only once. about nice table design see wiert.me/2014/04/03/…, – Zarko Nov 15 '17 at 23:48
4

enter image description here

\documentclass[a4paper,12pt]{article}
\usepackage[table]{xcolor}

\begin{document}
    \begin{tabular}{|*{4}{c|}}
\hline
\rowcolor{yellow}
a   &   b   &   c   &   d   \\
\hline
1   &   2   &   3   &   4   \\
\hline
    \end{tabular}
\end{document}

to my taste this is not nice table ... please, consider my comment above.

1

The upper of the following two tables may be close to what your second screenshot requires. However, I'd like to encourage that you give preference to the lower table, which deliberately has no colored header, no vertical lines, and fewer but well-spaced horizontal lines.

enter image description here

\documentclass{article}
\usepackage{array,booktabs,siunitx}
\newcolumntype{Q}[1]{>{\hfil$}p{#1}<{$\hfill}} % centered, automatic math mode
\usepackage[table]{xcolor} % for "\rowcolor" macro
\begin{document}

\begin{center}
\setlength{\extrarowheight}{2pt} % for a more "open" look
\begin{tabular}{|*{5}{Q{1cm}|}} % or: {|*{b}{c|}}
\hline
\rowcolor{yellow} a & b & a+b & a-b & b-a\\
\hline
2 &  3 &  5 & -1 &  1\\
\hline
4 & -2 &  2 &  6 & -6\\
\hline
3 & -5 & -2 &  8 & -8\\
\hline
\end{tabular}

\bigskip
\setlength{\extrarowheight}{0pt} % don't need this extra parameter anymore
\begin{tabular}{@{}S[table-format=1.0]*{4}{S[table-format=-1.0]}@{}} 
\toprule
{$a$} & {$b$} & {$a+b$} & {$a-b$} & {$b-a$}\\
\midrule
2 &  3 &  5 & -1 &  1\\
4 & -2 &  2 &  6 & -6\\
3 & -5 & -2 &  8 & -8\\
\bottomrule
\end{tabular}
\end{center}
\end{document}

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.