2

I'm using ShareLaTeX's Institute of Physics template for this project. I have created a few data tables and since the report I'm making is relatively long and may change in order, I want each one to have a label. I'm importing my data from CSV files and using the csvsimple package to create tables using its csvreader command in the figure enviornment. My issue is that, for some reason, after the first table, every subsequent label is printed out in the PDF.

I have tried using the showlabels package to prevent labels from being shown by using \usepackage[nolabels]{showlabels} and \usepackage[final]{showlabels}, but neither of those commands had any effect.

Here's the code that I'm using along with a couple of CSV files that I'm using and the output:

\documentclass[12pt,a4paper,final]{iopart}
\newcommand{\gguide}{{\it Preparing graphics for IOP journals}}
%Uncomment next line if AMS fonts required
\usepackage{iopams}  
\usepackage{graphicx}
\usepackage[breaklinks=true,colorlinks=true,linkcolor=blue,urlcolor=blue,citecolor=blue]{hyperref}
\usepackage{gensymb}
\usepackage{csvsimple}
\usepackage{caption}
\usepackage{array}
\usepackage{longtable}
\usepackage{amsmath}
\usepackage{float}
\usepackage[final]{showlabels}

\makeatletter
\newcommand\footnoteref[1]{\protected@xdef\@thefnmark{\ref{#1}}\@footnotemark}
\makeatother

\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{R}[1]{>{\raggedleft\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}

\begin{document}
\section{\label{sec:level1} Procedure}

\subsection{\label{sec:level2} Organization}
\subsection{\label{sec:level2} Trivialities and Setup-Determining Experiments}
\begin{table}[H]
    \label{tab: MassofMasses}
    \centering
    \caption{Actual Mass of Masses by Label}
    \csvreader[tabular=|C{1.5cm}|C{3cm}|, 
    table head=\hline Label & Mass (g)\\\hline,
    table foot=\hline]
    {ActualMassofMasses.csv}{Mass number=\label, Actual mass=\mass}
    {\label & \mass}
\end{table}

\begin{table}[H] \label{tab:CenterofMass} 
    \centering
    \caption{Distance from Tip of Hook to Center of Mass of Masses}
    \csvreader[tabular=|c|c|,
    table head=\hline Mass (g) & Distance (cm)\\\hline,
    table foot=\hline]
    {CenterofMass.csv}{mass=\mass, tip to CM=\distance}
    {\mass & \distance}
\end{table}

Output Output

Files needed (link to public google drive folder): https://drive.google.com/drive/u/1/folders/0B8iLMKPpwWqKeHZDNmhJSXIzazA

Thanks in advance for any help! Also, if I've missed anything that I need to include then please ask me for it.

2

There are also some other problems using your style and class files, but I can give a solution to the problem you described.

Your code line

{ActualMassofMasses.csv}{Mass number=\label, Actual mass=\mass}

redefines the standard \label macro. Note that this redefinition is global.

To avoid this, we could save and restore the original \label, but the preferred way would be to rename your private macro, e.g.

{ActualMassofMasses.csv}{Mass number=\mylabel, Actual mass=\mass}

The full code is:

\documentclass[12pt,a4paper,final]{iopart}
\newcommand{\gguide}{{\it Preparing graphics for IOP journals}}
%Uncomment next line if AMS fonts required
\usepackage{iopams}
\usepackage{graphicx}
\usepackage[breaklinks=true,colorlinks=true,linkcolor=blue,urlcolor=blue,citecolor=blue]{hyperref}
\usepackage{gensymb}
\usepackage{csvsimple}
\usepackage{caption}
\usepackage{array}
\usepackage{longtable}
\usepackage{amsmath}
\usepackage{float}
\usepackage[final]{showlabels}

\makeatletter
\newcommand\footnoteref[1]{\protected@xdef\@thefnmark{\ref{#1}}\@footnotemark}
\makeatother

\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{R}[1]{>{\raggedleft\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}

\begin{document}
\section{\label{sec:level1} Procedure}

\subsection{\label{sec:level2} Organization}
\subsection{\label{sec:level2} Trivialities and Setup-Determining Experiments}
\begin{table}[H]
    \label{tab: MassofMasses}
    \centering
    \caption{Actual Mass of Masses by Label}
    \csvreader[tabular=|C{1.5cm}|C{3cm}|,
    table head=\hline Label & Mass (g)\\\hline,
    table foot=\hline]
    {ActualMassofMasses.csv}{Mass number=\mylabel, Actual mass=\mass}
    {\mylabel & \mass}
\end{table}

\begin{table}[H] \label{tab:CenterofMass}
    \centering
    \caption{Distance from Tip of Hook to Center of Mass of Masses}
    \csvreader[tabular=|c|c|,
    table head=\hline Mass (g) & Distance (cm)\\\hline,
    table foot=\hline]
    {CenterofMass.csv}{mass=\mass, tip to CM=\distance}
    {\mass & \distance}
\end{table}
\end{document}

(The code above still has compilation errors due to the provided style and class files)

  • Thank you! I hadn't tried changing that because I didn't think those definitions were global. – nbingo Mar 27 '17 at 6:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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