1

I have multiple table with maths notations to link together. In each equation I need to point to the previous equation if needed so that we can trace back where eveything comes from. I need autmation because I have 48 input in table 1 and 43 equations in table 2.

However I would like to modify the ref number I have, and replace it with letters. It would help differenciate between values coming from an equation and values coming from an input table. Below is the expected example :

What I expect

For now I achieved this, I "just" need to replace 1. with i and 2. with p. This is done with this solution.

Achieved

"If" workaround

I have 3 tables to link in this document, could it be possible to insert an if condition inside this line ? Like if \thetable==1 i\arabic{...} else p\arabic{...}

\renewcommand{\therowcntr}{\thetable.\arabic{rowcntr}}

Code for all tables :

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage[danish]{babel}
\usepackage{lscape}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage[usenames,dvipsnames,svgnames,table]{xcolor}
\usepackage{float} 
\usepackage{array}
\usepackage[top=2.81cm, bottom=2.75cm,right=2cm, left=2cm]{geometry}

\usepackage{etoolbox} \usepackage{setspace} \onehalfspacing

\usepackage{url} \usepackage[hidelinks]{hyperref}

\hypersetup{breaklinks=true}

\newcounter{rowcntr}[table] \renewcommand{\therowcntr}{\thetable.\arabic{rowcntr}} \newcommand{\pref}[1]{(\ref{#1})}

% A new columntype to apply automatic stepping \newcolumntype{N}{>{\refstepcounter{rowcntr}\therowcntr}c}

% Reset the rowcntr counter at each new tabular \AtBeginEnvironment{tabular}{\setcounter{rowcntr}{0}}

\begin{document}

Achieved tables :

\begin{table}[H] \centering \caption{Input variable (i)} \label{tab:Q1} \begin{tabular}{|N|l|l|} \hline \multicolumn{1}{|c}{Number} & Unité & Notation \ \hline \label{gva_f} & $/an & $ gva_f $\ \label{dep_f} & $/an & $ dep_f $\ \end{tabular} \end{table}

\begin{table}[H] \centering \caption{Table of parameters (p)} \label{tab:Q2} \begin{tabular}{|N|l|l|} \hline \multicolumn{1}{|c}{Number} & Description & Equation \ \hline \label{gp_f} & This is a formula & $gp_f= gva_{f\pref{gva_f}} - dep_{f\pref{dep_f}}$\ \label{nc_f} & Another formula & $np_f= gp_{f\pref{gp_f}} - dep_{f\pref{dep_f}}$\ \end{tabular} \end{table}

Expected tables : \begin{table}[H] \centering \caption{Input variable (i)} \label{tab:Q1} \begin{tabular}{|c|l|l|} \hline Number & Unité & Notation \ \hline 1 & $/an & $ gva_f $\ 2 & $/an & $ dep_f $\ \end{tabular} \end{table}

\begin{table}[H] \centering \caption{Table of parameters (p)} \label{tab:Q2} \begin{tabular}{|c|l|l|} \hline Number & Description & Equation \ \hline 1 & This is a formula & $gp_f= gva_{f(i1)} - dep_{f(i2)}$\ 2 & Another formula & $np_f= gp_{f(p1)} - dep_{f(i2)}$\ \end{tabular} \end{table}

\end{document}

Gowachin
  • 131

1 Answers1

0

I achieved a part of solution. This is not perfect but acceptable.

I tested the "if" workaround to modify the aspect of the counter value each time it appears. However this require the modification of the table index at two places once I have their order in the final file (1 and 2 value in code).

It also modify the number in the first column of both tables but it's the price I'm ready to pay for now.

\newcounter{rowcntr}[table]
\renewcommand{\therowcntr}{
    \ifnum\thetable = 1
    i\arabic{rowcntr}
    \else 
        \ifnum\thetable = 2
        p\arabic{rowcntr}
        \else
        \thetable.\arabic{rowcntr}
        \fi
    \fi    
    }
\newcommand{\pref}[1]{(\ref{#1})}
Gowachin
  • 131