-1

I have problem with this 2 tables i am using \begin{center} ... \end{center} but the tables are not centered in the pdf. Anyone know what could be the problem.

\begin{table} [!ht]
\begin{center}
 \begin{tabular}{| c | c | c | c |} 
 \hline
Cost & Scenario 1: 100kWh & Scenario 2: 75kWh & Scenario 3: 50kWh \\[0.5ex] 
\hline \hline
CS1 revenues & 33,653 € & 33,645 € & 33,668 € \\ %[0.5ex] 
\hline
CS2 revenues & 33,712 € & 33,714 € & 33,685 € \\
 \hline
Load revenues & 5,400 € & 5,400 € & 5,400 € \\
 \hline
Export of electricity & 15 € & 43 € & 0 € \\
 \hline  
PV revenues & 5113 € & 5113 € & 5113 € \\
 \hline  
CHP revenues & 3215 € & 3215 € & 3215 €  \\
 \hline
Total operating income & 81,108 € & 81,130 € & 81,081 € \\
 \hline \hline   
Imported electricity & 24,604 € & 24,864 € & 21,269 €  \\ %[0.5ex] 
\hline
Natural gas cost & 3,700 € & 3,700 € & 3,700 € \\
 \hline
Total operating expenditure & 28,304 € & 28,564 € & 24,969 €  \\
 \hline 
Operating cost & -52,804 € & -52,566 € & -56,112 € \\
 \hline \hline 
\end{tabular}
\caption{Operating cost calculation}
 \label{Total annual cost}
\end{center}
\end{table}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Total Net Present Cost}
Net present cost is an economic tool to represent the life-cycle cost of a system. The total NPC calculates all the costs and revenues that occur within the project lifetime with future operating cost considering the interest rate. \\ 
%The total NPC cost has as equation: \\
% NPC= sum (annual cost Can,t for t from 0 to 9 years)+ Capital cost
%\begin{equation}
%\LC = \sum_{\myy=0}^{\lifetime}{\NPC{0} - \rp} + \ct
%\end{equation}
In table \ref{Project lifetime parameters}, the capital and maintenance cost, the project lifetime which is equal to the term loan, the operating cost and yearly repayment for the bank has been displayed to be used later. \\
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{table} [!ht]
\begin{center}
 \begin{tabular}{| c | c | c | c |} 
 \hline
Parameter & Scenario 1: 100kWh & Scenario 2: 75kWh & Scenario 3: 50kWh  \\[0.5ex] %$\ct$
\hline 
Capital and maintenance cost & 178,548 € & 163,548 € & 148,548 € \\[0.5ex] %$\ct$
\hline 
Interest rate  & 2\% & 2\% & 2\% \\ [0.5ex] %$\interest$
\hline
Project lifetime  & 10 years & 10 years & 10 years \\ %$\lifetime$
 \hline
Term loan  & 10 years & 10 years & 10 years \\ %$\lifetime$
 \hline
Yearly repayment for the bank & 17,855 € & 16,355 € & 14,855 € \\ % $\rb$
 \hline 
\end{tabular}
\caption{Project lifetime parameters}
 \label{Project lifetime parameters}
\end{center}
\end{table}
David Carlisle
  • 757,742
Ghaya
  • 11
  • 2
    Probably the table is wider than your text but as you (again) have provided no example that shows the issue it is hard to say. – David Carlisle Jan 05 '21 at 09:58
  • 1
    Depending on the documentclass you use, your table is most likely wider than the text width and thus appears to be shifted to the right. (Add \usepackage{showframe} to the preamble to see a visual representation of the text block and margin sizes) – leandriis Jan 05 '21 at 10:00
  • The easiest way to make your table more narrow is allowing linebreaks in the table headers, for example between "Scenario 1:" and "100kWh". (The makecell package could be useful for this.) Additionally, I also recomment replacing the center environment with \centering as the former adds vertical white space. – leandriis Jan 05 '21 at 10:03

2 Answers2

3
  • Please consider all comments below your question. You still can edit your question and add to it missed informations.
  • Command \centering or environment center center a table in text area, not on a page if (and only if) the width of a table is smaller than \textwidth.
  • If table is wider than \textwidth (what seems to be your case) table will start at left text border and spill-out at right text border, regardless if you use \centering or center command or environment respectively.
  • Your question is actually duplicate to this question.

As starting point for finding solution for your problem may serve the following example of MWE (Minimal Working Example, what we expect from you) with your table can be:

\documentclass{article}
%---------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%

\usepackage{siunitx} \usepackage{makecell} \setcellgapes{3pt}

\begin{document} \begin{table}[ht] \makegapedcells \centering \begin{tabular}{| l | c | c | c |} \hline Parameter & \makecell{Scenario 1:\ \SI{100}{\kWh}} & \makecell{Scenario 2:\ \SI{75}{\kWh}} & \makecell{Scenario 3:\ \SI{50}{\kWh}} \ \hline Capital and maintenance cost & 178,548 € & 163,548 € & 148,548 € \ \hline Interest rate
& \SI{2}{%} & \SI{2}{%} & \SI{2}{%} \ \hline Project lifetime
& 10 years & 10 years & 10 years \ \hline Term loan & 10 years & 10 years & 10 years \ \hline Yearly repayment for the bank & 17,855 € & 16,355 € & 14,855 € \ \hline \end{tabular} \caption{Project lifetime parameters} \label{Project lifetime parameters} \end{table} \end{document}

In above MWE are used packages:

  • siunitx for writing units
  • makecell for cells with multi lines text (used in column headers) and for adding vertical space around cells contents: space is set by \setcellgapes{<size>} and activated by macro \makegapedcells.

enter image description here

(redlines show page layout)

Zarko
  • 296,517
1

Your tables are too wide. One of the reasons is repetitions of data, for example “Scenario” repeated three times and € in most cells of the first table.

I make some suggestions about better rendering your tables: all repetitions are subsumed in a couple of places and siunitx facilities are used to get uniform printing of numbers.

I've also removed most rules, in particular the vertical ones that serve no purpose. I also changed the ugly Euro symbol with the official one.

Suppose that the journal you want to publish the paper in asks you to avoid comma separators for thousands, but a thin space. If you have prepared the document with siunitx, you will be able to comply by just changing one line of the code.

Don't use center, but \centering as shown below. Also, in order to terminate a paragraph a blank line is sufficient and \\ will produce spurious warnings.

\documentclass{article}
\usepackage{booktabs,eurosym,siunitx}

\sisetup{group-separator={,}}

\DeclareUnicodeCharacter{20AC}{\euro}

\begin{document}

\begin{table} [!htp] \centering

\sisetup{group-four-digits} % local setting

\begin{tabular}{l *{3}{S[table-format=-5.0]}} \toprule \multicolumn{1}{c}{Cost (€)} & \multicolumn{3}{c}{Scenarios} \ \cmidrule{2-4} & {1: \SI{100}{kWh}} & {2: \SI{75}{kWh}} & {3: \SI{50}{kWh}} \ \midrule CS1 revenues & 33653 & 33645 & 33668 \ CS2 revenues & 33712 & 33714 & 33685 \ Load revenues & 5400 & 5400 & 5400 \ Export of electricity & 15 & 43 & 0 \ PV revenues & 5113 & 5113 & 5113 \ CHP revenues & 3215 & 3215 & 3215 \ Total operating income & 81108 & 81130 & 81081 \ \midrule Imported electricity & 24604 & 24864 & 21269 \ Natural gas cost & 3700 & 3700 & 3700 \ Total operating expenditure & 28304 & 28564 & 24969 \ Operating cost & -52804 & -52566 & -56112 \ \bottomrule \end{tabular}

\caption{Operating cost calculation} \label{Total annual cost}

\end{table}

\subsection{Total Net Present Cost}

Net present cost is an economic tool to represent the life-cycle cost of a system. The total NPC calculates all the costs and revenues that occur within the project lifetime with future operating cost considering the interest rate.

In table \ref{Project lifetime parameters}, the capital and maintenance cost, the project lifetime which is equal to the term loan, the operating cost and yearly repayment for the bank has been displayed to be used later.

\begin{table} [!htp] \centering

\begin{tabular}{l c c c} \toprule \multicolumn{1}{c}{Parameter} & \multicolumn{3}{c}{Scenarios} \ \cmidrule{2-4} & 1: \SI{100}{kWh} & 2: \SI{75}{kWh} & 3: \SI{50}{kWh} \ \midrule Capital and maintenance cost (€) & \num{178548} & \num{163548} & \num{148548} \ Interest rate & 2% & 2% & 2% \ Project lifetime (years) & 10 & 10 & 10 \ Term loan (years) & 10 & 10 & 10 \ Yearly repayment for the bank (€) & \num{17855} & \num{16355} & \num{14855} \ \bottomrule \end{tabular}

\caption{Project lifetime parameters} \label{Project lifetime parameters}

\end{table}

\end{document}

enter image description here

If I comment out the \sisetup{group-separator={,}} line, the output becomes

enter image description here

so you see the convenience of inputting numbers in “abstract” form for subsequent processing according to one's preferences.

egreg
  • 1,121,712