# Redefining ref with renewcommand

In a thesis package, I must change \ref with \textnormal{\ref{tab8} \vspace{-3mm}} for format restrictions. I try \renewcommand,but i does not work. Below figure explains the problem. Any help will be appreciated. The class files will be found below link under this name Tez Yazım Şablonu(Latex). http://fbe.gsu.edu.tr/tr/belgeler/tez-yazimi An example code can be add to show extra spacing is:

    \documentclass[12pt,oneandhalf,chaparabic,ie,phd,eng,oneside,pntc]{gsufbe}
\usepackage{appendix}
\usepackage{graphicx}
\usepackage[fleqn]{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{tikz}
\usepackage{enumitem}
\usepackage{amsthm}
\usepackage{rotating}
\usepackage{booktabs}
\usepackage{array}
\usepackage[round]{natbib}
\usepackage{har2nat}
\usepackage{algorithmic}
\usepackage[ruled,noline]{algorithm2e}
\usepackage{titlesec}
\usepackage{multirow}
\usepackage{footnote}
\usepackage[section]{placeins}
\usepackage{float}
\usepackage{letltxmacro}
\RequirePackage{tikz}
\usetikzlibrary{%
arrows, backgrounds, calc,%
patterns, positioning, shapes.geometric%
}
\RequirePackage{pgfcalendar}
\makesavenoteenv{tabular}
\makesavenoteenv{table}

% End of Latex Packages
%
% Any personal Latex definition, declaration, etc.
\makeatletter
\let\old@includegraphics\includegraphics
\renewcommand{\includegraphics}[2][,]{%
\setbox9=\hbox{\old@includegraphics[#1]{#2}}%
\ifdim\wd9>\textwidth
\old@includegraphics[#1,width=\textwidth]{#2}%
\else
\old@includegraphics[#1]{#2}%
\fi%
}
\makeatother

\renewcommand\ref[1]{\textnormal{#1\vspace{-10mm}}}

\makeatletter
\def\upcase{\expandafter\makeupcase}
\def\makeupcase#1{\uppercase{#1}}

\newcommand{\FOO}{\textsc{\upcase foo}}
\makeatother
\author{NAZMİ ŞENER}
\title{Stochastic Programming Formulations of Discrete Hub Covering Location Problem}
\trtitle{Kes\.{I}kl\.{I} Ana Dağıtım Üssü Yerleş\.{I}m Kapsama Problemler\.{I}n\.{I}n Stokast\.{I}k Programlama \.{I}le Formülasyonları}
\date{May 2017}
\supervisor[prof]{JOHN DOE}
\departmentofsupervisor{Industrial Engineering Department}
\cosupervisor[assocprof]{JANE DOE}
\departmentofcosupervisor{Management}
\committeememberi[assistprof]{JAMES DOE}
\affiliationi{Industrial Engineering Department}
\affiliationii{Industrial Engineering Department}
\committeememberiii[assocprof]{RICK DOE}
\affiliationiii{Computer Engineering Department}
\keywords{STEEVE}
\motscles{STEEVE}
\anahtarklm{STEEVE}
\abstract{In recent years, .}
\oz{Son }

\acknowledgments{ Write your personal acknowledgements here.
}
\setlength{\jot}{10pt}
%%% !!! This two should be last lines before \begin{document}, do no move them !!!
\usepackage[draft,pdftex]{hyperref}
%\usepackage[all]{hypcap}
\usepackage[labelsep=space,hypcap]{caption}
\usepackage{subcaption}
\begin{document}
% Preliminaries
\newlength\myindent
\setlength\myindent{6em}
\newcommand\bindent{%
\begingroup
\setlength{\itemindent}{\myindent}
}
\newcommand\eindent{\endgroup}

\begin{preliminaries}
\end{preliminaries}
\newtheorem{thm}{Definition}[chapter]
\renewcommand{\thethm}{\arabic{chapter}.\arabic{thm}}
\newtheorem{prp}{Proposition}[chapter]
\renewcommand{\theprp}{\arabic{chapter}.\arabic{prp}}
\newenvironment{prf}{\noindent{\bf Proof}}{$\hfill \Box$ \vspace{10pt}}

\chapter{Results}
\thispagestyle{empty}
summarizes the model without taking care of inter-hub discount factor. It is obvious that
when the coverage radius becomes smaller, the performance measure also decreases. Another insight acquired from the table is there is no strong evidence to explain the relationship between hub opening cost and performance measure. On the other hand Table \ref{tab9} when standard deviation increases, the meaningfulness of stochastic modeling is also increasing. Solution times are generally higher when the radius is big.  Same way, when the standard deviation increases, solution times is also significantly increased. This relationship also occurs between hub opening costs and the solution times. \\

\begin{table}[ht]
\caption{Comparison of the Mean Performance of the Model for Log-N Distribution with Different Levels of Variance and Mean Solution Times (sec.) (Inter-hub Discount Factor=1)}
\centering
\label{tab9}

\begin{tabular}{|c|c|r|r|r|r|r|r|}
\hline
\parbox[t]{2mm}{\multirow{2}{*}{\rotatebox[]{90}{HOC}}}& \multirow{2}{*}{$R$} &\multicolumn{2}{c|}{Log-N($\sigma=0.5c(i,k))$}&\multicolumn{2}{c|}{Log-N($\sigma=c(i,k))$}&\multicolumn{2}{c|}{Log-N($\sigma=2c(i,k))$}\\
\cline{3-8}
&         &   {\small \% VSS/EEV} &   Time    &   {\small \% VSS/EEV} &   Time    & {\small \% VSS/EEV}   &   Time        \\
\hline
\parbox[t]{2mm}{\multirow{5}{*}{\rotatebox[]{90}{10,000}}}  &   0.7 $\Delta$    &   5.273   &   12154.3 &   13.967  &   26614.2 &   18.899  &   62474.8 \\
&   0.6 $\Delta$    &   5.178   &   9648.4  &   12.034  &   31224.9 &   15.988  &   58075.4 \\
&   0.5 $\Delta$    &   5.223   &   6802.9  &   10.176  &   16327.2 &   12.279  &   48422.3 \\
&   0.4 $\Delta$    &   3.865   &   5007.8  &   10.905  &   12250.5 &   13.025  &   39201.2 \\
&   0.3 $\Delta$    &   3.403   &   2404.2  &   7.107   &   6617.9  &   13.009  &   17396.5 \\  \hline
\parbox[t]{2mm}{\multirow{5}{*}{\rotatebox[]{90}{20,000}}}  &   0.7 $\Delta$    &   6.647   &   5561.3  &   13.689  &   16166.6 &   18.584  &   26126.5 \\
&   0.6 $\Delta$    &   6.004   &   4569.7  &   11.363  &   17305.8 &   15.363  &   31249.1 \\
&   0.5 $\Delta$    &   5.731   &   3721.2  &   12.065  &   12084.9 &   13.452  &   24147.5 \\
&   0.4 $\Delta$    &   5.129   &   2805.6  &   9.424   &   7313.3  &   11.441  &   19086.6 \\
&   0.3 $\Delta$    &   2.532   &   1938.1  &   4.933   &   4965.2  &   10.328  &   7444.4  \\  \hline
\hline
\end{tabular}
\end{table}
\bibliography{thesis_references}
\bibliographystyle{dcu}

\appendix
\thispagestyle{empty}

\end{document}


• no why would you do that?? \ref just makes a word that is part of a sentence why would you make the line following the line that has the reference 3mm higher so over-printing the current line if there are any large letters? – David Carlisle May 10 '17 at 20:29
• no, \ref adds no space. \ref will make text such as 1.2 why on earth do you want to add 3mm of negative vertical!! space on the line after whichever line of a paragraph has ... see section 1.2 ...  ??? – David Carlisle May 10 '17 at 20:33
• whatever made that space in your image is not \ref unless you have really broken ref. please show a small (complete) example that does that. – David Carlisle May 10 '17 at 20:37
• What's the difference to tex.stackexchange.com/questions/369008/…? – samcarter_is_at_topanswers.xyz May 10 '17 at 20:42
• the image shows you have a problem but we can not begin to guess what is the cause of the problem unless you show some code that does that. Clearly you have some incorrect definition, but redefining \ref to add vertical space would completely break any normal use of \ref in the document and is not the solution. – David Carlisle May 10 '17 at 20:47

The class file and the example document in the zip file show multiple mis-use of \vspace. the extra space shown in the image is from one of those, not from \ref.

Without an example posted, it's hard to guess exactly what produces the image but this shows a similar effect, using a definition in the thesis.tex example file.

\documentclass{article}
\usepackage{amssymb}
\newenvironment{prf}{\noindent{\bf Proof}}{$\hfill \Box$ \vspace{10pt}}

\begin{document}
\begin{prf}
One two three four five six seven eight nine ten.
One two three four five six seven eight nine ten.
One two three four five six seven eight nine ten.
One two three four five six seven eight nine ten.
One two three four five six seven eight nine ten.
\end{prf}
One two three four five six seven eight nine ten.
One two three four five six seven eight nine ten.
One two three four five six seven eight nine ten.
\end{document}


Note that the 10pt vertical space does not come immediately after the \Box but after the first line of the following paragraph. The extra space shown in your image is similarly after the first line of a paragraph, it will not be related to \ref.

With the example since added to the question, as posted it produces the error

! LaTeX Error: There's no line here to end.


as a quick emergency fix for that I changed \\ to \mbox{}\\ in the class file

then it produces

! Undefined control sequence.
\showresume ...ndhalfspacing \fi \fi \@resumetext


\def\@resumetext{}


to the top of the class file

It then ran without error but warned

Underfull \hbox (badness 10000) in paragraph at lines 106--108


which is from the misuse of \\ on that line in the document

so I changed

nd the solution times. \\


to

nd the solution times.


Then as egreg commented you get a big space mid-paragraph due to the spurious space in \thechapter

so change

\if@rmnchp \def\thechapter{\Roman{chapter}}
\else \def\thechapter{\vspace*{10pt} \arabic{chapter}} \fi


to

\if@rmnchp \def\thechapter{\Roman{chapter}}
\else \def\thechapter{\arabic{chapter}} \fi


Then the page looks like

That fixes the space

But you still get other serious warnings

Notably

(\end occurred inside a group at level 1)

### simple group (level 1) entered at line 1061 ({)
### bottom level
(\end occurred when \iftrue on line 96 was incomplete)


which means that the class really shouldn't be used for any actual document in its current state.

• I tried to change position of the '\ref' to another line, after that spacing also changes. I add another photo of this issue above. Thank you very much for your help and time. – nsener May 10 '17 at 21:15
• @nsener yes in your case but not really because of \ref. as egreg shows your reference expands in this case to \thechapter which has a faulty definition and adds the space you show. – David Carlisle May 10 '17 at 21:24
• The \end occurred inside a group at level 1 warning is due to algorithm2e. – egreg May 10 '17 at 21:48
• @egreg whatever, I wouldn't print a document with such errors:-) – David Carlisle May 10 '17 at 21:51

The class has

\if@rmnchp \def\thechapter{\Roman{chapter}}
\else \def\thechapter{\vspace*{10pt} \arabic{chapter}} \fi


This means that every time \thechapter is used, it will add a vertical space of 10pt after the line where the chapter number appears, in addition to a spurious horizontal space. Such usages are implicit in \ref{<label>} when the number to be referenced is based on \thechapter, for example a figure number.

Better code:

\if@rmnchp
\def\thechapter{\Roman{chapter}}
\else
\def\thechapter{\arabic{chapter}}
\fi