How to refer a table from one chapter in another chapter in a report - reference

I am writing a report, my document class is report, and I need to refer a table defined in one chapter in another chapter. I am using \usepackage{hyperref} too, however I am unaware of the code that has to be used in the text. Please help me to find a solution for this issue.

You should use the \label and \ref commands:
\label assigns a label (nomen omen) and can be given to an equation, a table, a figure.
\ref is used to refer to a particular label.
For example, if you have a figure and assign to it the label fig1 by using the command \label{fig1} then in the text you can refer to that figure by writing, for example
As it is clear in \ref{fig1}, the colors are bright and vivid.
Take a look here for some guidance. Down below you can find an example related to your question.
\documentclass{report}
\usepackage{lipsum}
\begin{document}
\chapter{First Chapter}
\lipsum[1]
\begin{table}[htbp]
\begin{center}
\begin{tabular}{c|c|c}
A & B & C\\
\hline
1 & 2 & 3\\
4 & 5 & 6
\end{tabular}
\end{center}
\caption{A table}\label{tab}
\end{table}
\lipsum[1-3]
\chapter{Second chapter}
In this chapter we are referring to Table \ref{tab}. In the following we analyse the data and compare them to Table \ref{tab2}.
\begin{table}[htbp]
\begin{center}
\begin{tabular}{c|c|c}
D & E & F\\
\hline
-1 & -2 & -3\\
-4 & -5 & -6
\end{tabular}
\end{center}
\caption{Another table}\label{tab2}
\end{table}
\end{document}
You may use also the package cleveref to let Latex handle the correct names of labelled environments (equations, tables, figures...).

You can use latex's \label/\ref mechanism like in the following example:
\documentclass{report}
\usepackage{hyperref}
\begin{document}
\chapter{chapter 1}
\begin{table}[htbp]
...
\caption{some table}
\label{mytable}
\end{table}
\chapter{chapter 2}
see my table \ref{mytable}
\end{document}

Related

How to center this piece of text in ShareLateX (editor) or Latex (in general)?

I am writing a resume and want to center text at the top of the document which contains my name and email details, like this
I used \begin{center} and \end{center} but it doesnt seem to work
Here is my code:
\begin{document}
\begin{tabular*}{\linewidth}{l#{\extracolsep{\fill}}r}
\vspace{-4mm}
\textbf{\LARGE Samuel Adams}
\\
& \\ \textbf{Notsville, TX} $|$
\textbf{\phone \ \ +1 (000) 000 0000} $|$
\textbf{cxcx#gmail.com} $|$ \textbf{{www.linkedin.com/ffdfs}}\\
\end{tabular*}
\vspace{1 mm}
Can anyone help me center this piece of text?
This is how it looks right now. I am looking to center both lines just like we do it in word.
The table will be in the middle of the page once
you make the left and right margin the same size
use \noindent in front of the table to avoid it being indented as the first line of a new paragraph
(I'm actually not sure why you use a table for this, you never use the second column...)
\documentclass[a4paper,10pt]{article}
\usepackage[empty]{fullpage}
\usepackage{xcolor}
\usepackage{url}
\usepackage{wasysym}
\usepackage{hyperref}
\usepackage{enumitem}
\usepackage[utf8]{inputenc}
\usepackage[a4paper,bindingoffset=0.3in, left=0.5in,right=0.5in,top =0.8in,bottom=-5in, footskip=.25in]{geometry}
\begin{document}
\noindent\begin{tabular*}{\linewidth}{l#{\extracolsep{\fill}}r}
\textbf{\LARGE Samuel Adams} & \\
\textbf{Notsville, TX} $|$ \textbf{\phone \ \ +1 (000) 000 0000} $|$
\textbf{cxcx#gmail.com} $|$ \textbf{{www.linkedin.com/ffdfs}} & \\
\hline
\end{tabular*}
\vspace{1 mm}
\end{document}

newcommand containing loop causes an error in a tabular

I have the little program below where some cells of a tabular are built by a newcommand. If the newcommand content is put directly in the tabular, all is ok. If I embed a new command, I get "Missing number, treated as 0" at the calling line.
\documentclass[a4paper]{article}
\usepackage[utf8]{inputenc}
\title{test}
\author{myself}
\date{\today}
\begin{document}
\maketitle
\def\tand{&}
\newcounter{i}
\newcommand{\doit}{
\makeatletter
\setcounter{i}{3}
\#whilenum\value{i}>0\do{}
{
P\value{i} \tand%
\addtocounter{i}{-1}
} %
\makeatother
P0 %
}
\newcounter{it}
\begin{tabular}{|c|c|c|c|}
3 & 2 & 1 & 0 \\
\doit \\
\end{tabular}
\end{document}
Help would be welcome.

Concatenate a series of plots in a list in to a composite plot?

I've normally generated and appended charts to a list in order to later combine them (e.g. sequential multi-year plots for a given location).
For instance:
group1= (chart1 + line1 + point1_hist + min_max_rule + point_max_hist + point_min_hist | legend1)
plot_group.append(group1)
And then creating a final chart from this list.
chart= plot_group[0] & plot_group[1] & plot_group[2] & plot_group[3]
This works fine for a fixed number of component plots.
But, for a variable number of plots, I can't figure how to automatically generate the final chart since the altar chart structure using '&' is not a standard python syntax that I can construct with a simple loop, as far as I can tell.
Is there any convention in Altair to simply concatenate a series of plots in a list in to a composite plot?
The & operator is a shortcut for alt.vconcat, which can accept multiple arguments:
chart=alt.vconcat(*plot_group)

Matlab - Using symbols in gscatter

Ok, so I'm trying to use gscatter to plot 8 different points in a figure. These 8 points are all different and thus I want to give them different symbols. I know that gscatter will automatically assign them different colors, but I also want to be able to use the figure in black and white. I have written the following code:
lincol = {'k';'k';'k';'k';'k';'k';'k';'k'};
linsym = {'+';'o';'*';'.';'x';'s';'d';'^'};
limits = [-1 1 -1 1];
close all
for i = 1:3;
figure(i); hold on
gscatter(RfootXdistpertRel(:,i),RfootYdistpertRel(:,i),lincol,linsym);
legend('Pert1', 'Pert2', 'Pert3', 'Pert4', 'Pert5', 'Pert6', 'Pert7', 'Pert8')
hline(0);
vline(0);
axis(limits);
end
According to the matlab syntax, I should be able to specify color and marker symbol in this way (gscatter(x,y,col,sym)). The variables used are 8 by 1 vectors, just as the lincol and linsym. However, it gives me an error:
Error using plot
Color value must be a 3 or 4 element vector
Can anyone help? It's just such a silly problem to have.
Luc
It seems that you have some errors in your code. The syntax for gscatter should include at least 3 parameters : x, y and group. It seems that group is missing.
Furthermore the definition of color and sym may be wrong. Try col = 'kkkkkkkk'; instead of lincol = {'k';'k';'k';'k';'k';'k';'k';'k'};.
I hope this helps.
Regards.
Jonay

How do I group strings and their data using Gnuplot?

I'm brand new to Gnuplot and want to be able to graph a huge amount of data that looks like this:
Description violFine state
"Red Light Violation" $75.00 MD
"No Stop/Park Handicap" $502.00 MD
"Red Light Violation" $75.00 MD
"No Stop/Park Handicap" $502.00 MD
"Red Light Violation" $75.00 MD
"Red Light Violation" $75.00 MD
"Red Light Violation" $75.00 VA
"All Other Stopping or Parking Violations" $32.00 MD
"Red Light Violation" $75.00 MD
"Red Light Violation" $75.00 MD
As you can see, the top line is the names of the columns and I have many duplicate string values in the "Description" column. What I want to do is add up all the "violFine" numbers per unique "Description" and plot it with the "Description" on the x-axis and the total of the "violFines" on the y-axis. I've made a graph to illustrate what I'm talking about accessible at this link: http://i.imgur.com/NtZsZCR.jpg
(Sorry, I would've made it available on this page if I had enough reputation points).
Any help with going about this would be awesome! Thanks!
This sort of data processing task isn't well suited for gnuplot. Luckily, gnuplot is happy to let you use other tools to process the data and then pipe the result in. Here, I would use python:
from collections import defaultdict
import csv
import sys
d = defaultdict(list)
with open(sys.argv[1]) as fin:
next(fin) #remove the first line which doesn't contain data
reader = csv.reader(fin,delimiter=' ',quotechar='"')
for row in reader:
d[row[0]].append(float(row[1][1:]))
for k,v in d.items():
print '"{0}"'.format(k),sum(v)
Now in gnuplot, you can plot this as:
plot '< python script.py datafilename' using (column(0)):2:xtic(1) with lines
You can also do it in gnuplot only without external tools.
define a function inList(), which determines if an item is already in the list
create a list of unique items
define a function to get the index (i.e. x-value) of an item in the unique list
sum up the second column (after removing $) for equal x-values via smooth freq
every ::1 is skipping the first (header) line
For gnuplot>=5.0.0 you could also use sum and word() for the function inList(), which, however doesn't work for gnuplot 4.x because word() will ignore matching double quotes, e.g. word('"abc def" ghi',2) will return ghi in gnuplot 5.x, but def" in gnuplot 4.x. Hence, for 4.x there is another approach using strstrt() and adding an index number which will also work for 5.x
Script: (works for gnuplot>=4.6.0, March 2012)
### sum up values depending on keyword
reset
FILE = "SO/SO15316764.dat"
# create list of unique elements
c = 0
uniq = ''
inList(list,s) = strstrt(list,'"'.s.'"')
stats FILE u (uniq=uniq.(inList(uniq,strcol(1)) ? '' : sprintf('"%s" %d ',strcol(1),c=c+1))) every ::1 nooutput
getIndex(list,s) = (_n=inList(list,s)) ? int(word(list[_n+2+strlen(s):],1)) : 0
set boxwidth 0.8
set style fill solid 0.4
set key noautotitle
set xrange[0.5:c+0.5]
plot FILE u (getIndex(uniq,strcol(1))):(real(strcol(2)[2:])):xtic(1) every ::1 smooth freq w boxes
### end of script
Result:

Resources