Text FormattingAutomatic Table from Command

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
User avatar
Orwel
Posts: 4
Joined: Wed Mar 27, 2013 2:16 am

Automatic Table from Command

Post by Orwel »

Hello,

I want to create a table, who is automatic to fill. It is to make listing of modification in my document.

This is my declaration of table.

Code: Select all

\begin{tabularx}{17cm}{|l|l|X|}
\hline
\multicolumn{3}{|c|}{} \\
\multicolumn{3}{|c|}{\large{\textbf{Historique des modifications}}}\\
\multicolumn{3}{|c|}{} \\
\hline
Version & Date & Description de la modification \\
\hline
Test V & Test D & Test M \\
\hline 
\listmodifs \\
\hline
\end{tabularx}
Now, declaration my variable listmodifs.

Code: Select all

\newcommand{\modifications}[1]{%
  \def\listmodifs{#1}

  % That is functors !!!
  \def\version{\shortcomment}
  \def\dateModif{\shortcomment}
  \def\description{\longdetails}
}
Now, how I call my function modifications.

Code: Select all

\modifications{
  \version{00} \dateModif{01/11/2012} \description{Version initiale}
  \version{01} \dateModif{07/01/2013} \description{Modification de la planification du projet} 
  \version{02} \dateModif{28/01/2013} \description{Refonte du cahier de spécifications}
  \version{03} \dateModif{04/02/2013} \description{Réécriture en LaTeX}
  \version{04} \dateModif{20/02/2013} \description{Diverse modification mineure}
  \version{04} \dateModif{09/03/2013} \description{Mise en place UseLATEX.cmake}
}
I have try something, but nothing work correctly. How to do this?
Last edited by localghost on Wed Mar 27, 2013 11:09 am, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

tom
Posts: 73
Joined: Thu Apr 18, 2013 4:02 am

Automatic Table from Command

Post by tom »

Hey!

I would go about it slightly differently. Take a look at the code below, it's pretty straight forward.

Code: Select all

\documentclass[12pt, a4paper]{article}

\usepackage{tabularx}

\newcommand*{\addmod}[3]{%
  #1 & #2 & #3 \\
}
\newcommand*{\fillTable}{%
  \addmod{00}{01/11/2012}{Version initiale}
  \addmod{...}{...}{...}
}

\begin{document}
\begin{tabularx}{17cm}{|l|l|X|}
\hline
\multicolumn{3}{|c|}{} \\
\multicolumn{3}{|c|}{\large{\textbf{Historique des modifications}}}\\
\multicolumn{3}{|c|}{} \\
\hline
Version & Date & Description de la modification \\
\hline
Test V & Test D & Test M \\
\hline
\fillTable
\hline
\end{tabularx}
\end{document}
User avatar
Orwel
Posts: 4
Joined: Wed Mar 27, 2013 2:16 am

Automatic Table from Command

Post by Orwel »

Thank for you solution, but I have problem with.
fillTable is declared in Document.tex and the table is in class.

But how I can define function tableCDS with fillTable in class.

Code: Select all

\newcommand{\tableCDS}{
  \begin{tabularx}{17cm}{|l|l|X|}
  \hline
  \multicolumn{3}{|c|}{} \\
  \multicolumn{3}{|c|}{\large{\textbf{Historique des modifications}}}\\
  \multicolumn{3}{|c|}{} \\
  \hline
  Version & Date & Description de la modification \\
  \hline
  Test V & Test D & Test M \\
  \hline
  \fillTable
  \hline
  \end{tabularx}
}
And redefine (like poly-morphing) \fillTable in Document.tex?
Last edited by localghost on Sat Jun 15, 2013 5:00 pm, edited 1 time in total.
Post Reply