0

The main problem is just how to get a section reference working, specifically in TeXMaker. I've never used \ref and \label before, so this is a first for me. I've done a little work searching for a solution, but haven't gotten too far.

Currently I'm at the stage where I run the program and two question marks appear when instead of the referenced section number. For syntax and such, sites like this and this are good for starting out, assuming that your only question is about syntax; however, none of these seem to really expand on what it is that's going on behind the \label and \ref commands.

So I looked to see what was going on behind the scene, because I recently tried and failed to use BibLaTex, so I found explanations like this and this, from which I get that if I am doing everything right in my code, then I should ideally be able to make a series of runs that will build the PDF and then fill the section numbers. If that is my only problem, then I don't know how to do that in TeXMaker anyways, because I wasn't sure which Configure->Quick Build option should work to get the right sequence of runs.

However, even those large explanations about how the file runs work doesn't apply specifically to TeXMaker, and so I was hesitant to go too much off of those for fear that TeXMaker as a compiler had a specific problem on it's own, or that one of my numerous packages was messing something up. The basic code I've tried to run is below, with all the preamble commands that I normally use.

\documentclass[12pt]{article}
%\DeclareMathSizes{12}{12}{12}{12}

%Formatting Libraries
\usepackage[english]{babel}
\usepackage[latin1]{inputenc}
\usepackage[autostyle, english = american]{csquotes}
\MakeOuterQuote{"}
\usepackage{listings}
\usepackage{keyval}
\usepackage{xcolor}
\usepackage{textcomp}
\usepackage{fullpage}
\usepackage{setspace}
\usepackage{graphicx}
\usepackage{hyperref}
\usepackage{verbatim}
%\usepackage[]{mcode}
\usepackage{multicol}
\usepackage{float}
\usepackage{framed}

%References %To be attempted at a later date
%\usepackage[backend=biber,bibencoding=latin1,style=verbose-trad2]{biblatex}
%\bibliography{biblio.bib} 
%\addbibresource{biblio.bib}
%\usepackage{cite}

%For MATLAB Code
\usepackage{listings}
\usepackage{color} %red, green, blue, yellow, cyan, magenta, black, white
\definecolor{mygreen}{RGB}{28,172,0} % color values Red, Green, Blue
\definecolor{mylilas}{RGB}{170,55,241}

%Symbols Libraries
\usepackage[fleqn]{amsmath}
\usepackage{amssymb}
\usepackage{amsfonts}
\usepackage{amsthm}
\usepackage{marvosym}
\usepackage{wasysym}

%For Image Generation
\usepackage{tikz}
\usetikzlibrary{intersections}
\usetikzlibrary{arrows}

%For Theorem Environment
\newtheorem{theorem}{Theorem}
\newtheorem{lemma}{Lemma}
\renewcommand\qedsymbol{$\blacksquare$}

\begin{document}

\section{Introduction} \label{intro}
lalala

\section{Section 1}
\indent Here in \ref{sec:intro}.

\end{document}
  • 4
    Welcome to TeX.SX! The fact you're using Texmaker is irrelevant as far as the labels and references are concerned. – egreg Dec 2 '17 at 15:47
  • Most probably off-topic here, but you're loading hyperref too early – user31729 Dec 2 '17 at 15:51
  • 1
    Just make sure that the keys used for \label and \ref match, e.g. \label{sec:intro} and \ref{sec:intro}. – Troy Dec 2 '17 at 15:55
  • @Troy: Observed well -- did not spot that the OP uses \label{intro} only – user31729 Dec 2 '17 at 15:59
3

TeXmaker is not at all relevant to the discussion about labels and references here -- it is just a front-end editor. Just make sure that the labels and references share the same key, that is:

\documentclass{article}
\begin{document}
    \section{Introduction}\label{sec:intro}% <------
    Hello world, I am in Section~\ref{sec:intro}. % <------
\end{document}

enter image description here

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.