TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to make a table like this, but I'm still having some problems:

  1. can't put the text in center of the box
  2. can't \flushleft the table title
  3. can't itemize in the table

enter image description here

Help me!

Here is my LATEX

\documentclass[12pt,fleqn]{book}

\usepackage[top=3cm,bottom=3cm,left=3.75cm,right=2.25cm,headsep=10pt,a4paper]{geometry} % Page margins

\usepackage{graphicx} % Required for including pictures
\graphicspath{{Pictures/}} % Specifies the directory where pictures are stored

\usepackage{lipsum} % Inserts dummy text

\usepackage{tikz} % Required for drawing custom shapes

\usepackage[english]{babel} % English language/hyphenation

\usepackage{enumitem} % Customize lists
\setlist{nolistsep} % Reduce spacing between bullet points and numbered lists

\usepackage{booktabs} % Required for nicer horizontal rules in tables

\usepackage{xcolor} % Required for specifying colors by name

\usepackage{array}
\usepackage{caption}
\usepackage{float}

\begin{document}

\newcommand{\tabitem}{~~\llap{\textbullet}~~}

%%% FOR TABLE
\newcommand{\signaldes}[3]
{#1 & #2 & #3 \\ \hline}

\newcommand{\groupsignal}[1]
{
    %\begin{centering}
    %#1 \\ \hline
    \multicolumn{3}{|c|}{\bfseries{#1}} \\ \hline
    %\end{centering}
}   

\newenvironment{signaltable}[1]
    {%\ttabbox[\FBwidth]{}{%
        %\captionsetup{justification=raggedleft,singlelinecheck=off}
        \captionof{table}{Signal Description Table #1} \label{tab:title}
    \begin{tabular}%{>{\bfseries}c c c}%
        {|l | l | p{8cm} |} %>{\bfseries}: in đậm 
        \specialrule{2pt}{1pt}{1pt}
        \bfseries{Signal} & \bfseries{Source} & \bfseries{Description} \\
        \specialrule{2pt}{1pt}{1pt} 
        %\bfseries{#1} & #2 & #3. \\
        %\hline
    %}
    }
    {   
    \end{tabular}}

\section*{SECTION1}
\lipsum[1]

\section*{SECTION2}
\begin{signaltable}{Bus AXI}
  \signaldes{s\_axi\_lite\_aclk}{SLAVER}{AXI DMA AXI4-Lite Clock. Must be less than or equal to axi\_sg\_aclk for asynchronous mode.(C\_PRMRY\_IS\_ACLK\_ASYNC=1).}
  \signaldes{m\_axi\_sg\_aclk}{MASTER}{AXI DMA Scatter Gather Clock. Scatter Gather clock must be less than or equal to the slowest of m\_axi\_mm2s\_aclk or m\_axi\_s2mm\_aclk for asynchronous mode.(C\_PRMRY\_IS\_ACLK\_ASYNC=1).}
  \signaldes{m\_axi\_mm2s\_aclk}{MASTER}{AXI DMA MM2S Primary Clock}
  \signaldes{m\_axi\_s2mm\_aclk}{MASTER}{AXI DMA S2MM Primary Clock}
  \groupsignal{AXI4 Lite Interface Signals}
  \signaldes{s\_axi\_lite\_awvalid}{SLAVER}{AXI4-Lite Write Address Channel Write Address Valid.
    \textbullet\ 1 = Write address is valid.\\
    \textbullet\ 0 = Write address is not valid.}
  \signaldes{s\_axi\_lite\_awready}{SLAVER}{AXI4-Lite Write Address Channel Write Address Ready. Indicates DMA ready to accept the write address.\\
    \tabitem 1 = Ready to accept address.\\
    \tabitem 0 = Not ready to accept address.}
\end{signaltable}

\end{document}
share|improve this question
2  
Instead of yelling "HELP ME" perhaps you could post some code that shows what you've tried and what is causing you problems. A complete, compilable minimal document (no extra packages, code etc.) Also, have you searched the site for table formatting questions? There are lots of examples of how to do this already on the site. – Alan Munn Feb 16 at 7:25
    
Tks for your recomment. I had posted my code above, you can use to try to fix it. – Yuri Feb 16 at 7:32
up vote 8 down vote accepted

The vertical centering can be obtained using the m columntype which has the width of the column as an argument.

I used a tabularx table to provide the rest of the available width for the Description column, using X columntype.

Both p and X allow wrapping of longer lines as well as enumeration or itemize environments.

I omitted the vertical lines on purpose as they do not improve readability.

\documentclass{book}
\usepackage{tabularx}

\usepackage[top=3cm,bottom=3cm,left=3.75cm,right=2.25cm,headsep=10pt,a4paper]{geometry}
\usepackage{booktabs}
\usepackage{array}

\newlength{\smallcolumnwidth}
\setlength{\smallcolumnwidth}{1.2cm}
\begin{document}
\sffamily
\noindent\begin{tabularx}{\linewidth}{*{4}{p{\smallcolumnwidth}}X}
\toprule[1.5pt]
\multicolumn{1}{m{\smallcolumnwidth}}{\textbf{Signal Name}} & \multicolumn{1}{m{\smallcolumnwidth}}{\textbf{Interface}} & \multicolumn{1}{m{\smallcolumnwidth}}{\textbf{Signal Type}} & \multicolumn{1}{m{\smallcolumnwidth}}{\textbf{Init Status}} &  \textbf{Description} \tabularnewline
\midrule[1pt]
foo & foo & foo & foo & A longer longer longer text that is most likely wrapped around \tabularnewline

\midrule
foo & foo & foo & foo & Another longer text that is most likely wrapped around again \tabularnewline
\midrule
foo & foo & foo & foo & A longer text that is not wrapped around \tabularnewline
\midrule
\multicolumn{5}{m{\dimexpr\linewidth-2\tabcolsep}}{\centering \textbf{AXI4-Lite Interface Signals}} \tabularnewline
\midrule
  foo & foo & foo & foo & foo 
  \begin{itemize}
  \item foo
  \item another foo
  \end{itemize} \tabularnewline
\bottomrule
\end{tabularx}
\end{document}

enter image description here

share|improve this answer
    
I won't fill in the text for the O.P. of course ;-) – Christian Hupfer Feb 16 at 7:54
    
How about editing my code? :D – Yuri Feb 16 at 8:09
    
@ChristianHupfer I would also recommend to start and end the definition of columns with @{} to get rid of the extra space at the start of the leftmost and end of the rightmost column in the table. – Sveinung Feb 16 at 22:31

can't put the text in center of the box

I suggest the tabulary package (or tabularx suggested by Christian, depending of type of columns of the table you may want one or another)

can't \flushleft the table title

\captionsetup{justification=raggedright, singlelinecheck=off}

can't itemize in the table

Use a \parbox. It is essentially the same that use a p column, but you can use also it in another column types.

A reduced MWE:

mwe

\documentclass[12pt,fleqn,a4paper]{book}
\usepackage{booktabs} % Required for nicer horizontal rules in tables
\usepackage{caption}
\captionsetup{justification=raggedright, singlelinecheck=off}
\usepackage{tabulary}
\begin{document}
\begin{table}
\caption{Signal Description Table Bus AXI}  
\begin{tabulary}{\linewidth}{llccLL}
\toprule
s\_axi\_lite\_aclk &
SLAVER & 
I & & AXI DMA AXI4-Lite Clock. Must be less than or equal to axi\_sg\_aclk for asynchronous mode. (C\_PRMRY\_IS\_ACLK\_ASYNC=1) \\
\midrule
\multicolumn{5}{c}{\bfseries AXI4 Lite Interface Signals}\\
\midrule
 s\_axi\_lite\_awvalid & 
 SLAVER & 
 O & 0 & 
 AXI4-Lite Write Address Channel Write Address Valid. 
%\parbox{\linewidth}{
\begin{itemize}
\item 1 = Write address is valid.
\item 0 = Write address is not valid.   
\end{itemize}
%}
\tabularnewline\bottomrule 
\end{tabulary}
\end{table}
\end{document}
share|improve this answer
    
Oh, I saw that I forgot the caption ;-) – Christian Hupfer Feb 16 at 8:10

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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