Math & ScienceCommand \ref don't work correctly

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
agsh
Posts: 5
Joined: Mon Jun 26, 2023 2:05 pm

Command \ref don't work correctly

Post by agsh »

Hello all!

I typed the following equations:

Code: Select all

\documentclass{article}

\usepackage[T2A]{fontenc}
\usepackage[utf8]{inputenc}

\usepackage{amsmath, eqnarray}

\usepackage[colorlinks=true]{hyperref}

\begin{document}
    
\vspace*{30\baselineskip}

\bgroup\arraycolsep 0.1em
\begin{equationarray}{*{9}{c}}
    M \ddot x & + & D_s \dot x & + & K x & = &
    F \cos(\omega t + \delta) & + & P \cos(\gamma) \label{eq1} \\[6pt]
    \underset{\substack{\text{сила} \\ \text{инерции}}}{M \ddot y} & + &
    \underset{\substack{\text{сила} \\ \text{вязкого} \\ \text{трения}}}{D_s \dot y}  & + &
    \underset{\substack{\text{сила} \\ \text{упругости}}}{K y} & = &
    \underset{\substack{\text{внешняя} \\ \text{вращающаяся} \\ \text{возбуждающая} \\ \text{сила}}}{F \sin(\omega t + \delta)} & + &
    \underset{\substack{\text{постоянная} \\ \text{радиальная} \\ \text{сила} \\ \text{нагружения}}}{P \sin(\gamma)} \label{eq2}
\end{equationarray}
\egroup


Уравнения \ref{eq1} и \ref{eq2} имеют типичную форму дифференциальных уравнений\ldots

\end{document}
Image

I see generated links to equations 1 and 2 and all looks like fine. But when I click them pdf page don't scroll to equation, but to the top of the page. How can I solve this problem?

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
agsh
Posts: 5
Joined: Mon Jun 26, 2023 2:05 pm

Command \ref don't work correctly

Post by agsh »

Just tried this solution: https://tex.stackexchange.com/a/102845

Code: Select all

\documentclass{article}

\usepackage[T2A]{fontenc}
\usepackage[utf8]{inputenc}

\usepackage{amsmath}

\usepackage[colorlinks=true]{hyperref}

\newcommand*\centermathcell[1]{\omit\hfil$\displaystyle#1$\hfil\ignorespaces}

%\usepackage[showframe=true]{geometry}

\begin{document}
    
    \begin{alignat}{9}
        \centermathcell{M \ddot x} & + &
        \centermathcell{D_s \dot x} & + &
        \centermathcell{K x} & = &
        \centermathcell{F \cos(\omega t + \delta)} & + &
        \centermathcell{P \cos(\gamma)} \label{eq1} \\[6pt]
        \underset{\substack{\text{сила} \\ \text{инерции}}}{M \ddot y} & + &
        \underset{\substack{\text{сила} \\ \text{вязкого} \\ \text{трения}}}{D_s \dot y}  & + &
        \underset{\substack{\text{сила} \\ \text{упругости}}}{K y} & = &
        \underset{\substack{\text{внешняя} \\ \text{вращающаяся} \\ \text{возбуждающая} \\ \text{сила}}}{F \sin(\omega t + \delta)} & + &
        \underset{\substack{\text{постоянная} \\ \text{радиальная} \\ \text{сила} \\ \text{нагружения}}}{P \sin(\gamma)} \label{eq2}
    \end{alignat}
    
\end{document}
Unfortunatelly, not so good, as I expected...

Image
agsh
Posts: 5
Joined: Mon Jun 26, 2023 2:05 pm

Command \ref don't work correctly

Post by agsh »

Tried this: https://www.latex4technics.com/?note=2IYU

Code: Select all

\documentclass{article}

\usepackage[T2A]{fontenc}
\usepackage[utf8]{inputenc}

\usepackage{amsmath}

\usepackage[colorlinks=true]{hyperref}

\newcommand*\centermathcell[1]{\omit\hfil$\displaystyle#1$\hfil\ignorespaces}

\usepackage[showframe=true]{geometry}

\newcommand{\ccol}[1]{\omit\ensuremath{\hfill #1\hfill}}

\begin{document}
    
    \begin{align}
        \ccol{M \ddot x}
        & + &
        \ccol{D_s \dot x}
        & + &
        \ccol{K x}
        & = &
        \ccol{F \cos(\omega t + \delta)}
        & + &
        \ccol{P \cos(\gamma) \label{eq1}} \\[6pt]
        %
        \ccol{\underset{\substack{\text{сила} \\ \text{инерции}}}{M \ddot y}} & + &
        \ccol{\underset{\substack{\text{сила} \\ \text{вязкого} \\ \text{трения}}}{D_s \dot y}}  & + &
        \ccol{\underset{\substack{\text{сила} \\ \text{упругости}}}{K y}} & = &
        \ccol{\underset{\substack{\text{внешняя} \\ \text{вращающаяся} \\ \text{возбуждающая} \\ \text{сила}}}{F \sin(\omega t + \delta)}} & + &
        \underset{\substack{\text{постоянная} \\ \text{радиальная} \\ \text{сила} \\ \text{нагружения}}}{P \sin(\gamma)} \label{eq2}
    \end{align}
    
\end{document}
Even worse result...

Image
User avatar
Stefan Kottwitz
Site Admin
Posts: 10290
Joined: Mon Mar 10, 2008 9:44 pm

Command \ref don't work correctly

Post by Stefan Kottwitz »

Welcome to the forum!

You could use alignat, for example:

Code: Select all

\documentclass{article}
\usepackage[T2A]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage[colorlinks=true]{hyperref}
\newcommand*\centermathcell[1]{\omit\hfil$\displaystyle#1$\hfil\ignorespaces}
\usepackage[showframe=true]{geometry}
\newcommand{\ccol}[1]{\omit\ensuremath{\hfill #1\hfill}}
\begin{document}
    \begin{alignat}{5}
        &\ccol{M \ddot x}
        && + &
        \ccol{D_s \dot x}
        && + &
        \ccol{K x}
        && = &
        \ccol{F \cos(\omega t + \delta)}
        && + &
        \ccol{P \cos(\gamma) \label{eq1}} \\[6pt]
        %
        &\ccol{\underset{\substack{\text{сила} \\ \text{инерции}}}{M \ddot y}} && + &
        \ccol{\underset{\substack{\text{сила} \\ \text{вязкого} \\ \text{трения}}}{D_s \dot y}}  && + &
        \ccol{\underset{\substack{\text{сила} \\ \text{упругости}}}{K y}} && = &
        \ccol{\underset{\substack{\text{внешняя} \\ \text{вращающаяся} \\ \text{возбуждающая} \\ \text{сила}}}{F \sin(\omega t + \delta)}} && + &
        \underset{\substack{\text{постоянная} \\ \text{радиальная} \\ \text{сила} \\ \text{нагружения}}}{P \sin(\gamma)} \label{eq2}
    \end{alignat}
\end{document}
Stefan
LaTeX.org admin
agsh
Posts: 5
Joined: Mon Jun 26, 2023 2:05 pm

Command \ref don't work correctly

Post by agsh »

Stefan Kottwitz wrote:Welcome to the forum!

You could use alignat, for example:

Code: Select all

\documentclass{article}
\usepackage[T2A]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage[colorlinks=true]{hyperref}
\newcommand*\centermathcell[1]{\omit\hfil$\displaystyle#1$\hfil\ignorespaces}
\usepackage[showframe=true]{geometry}
\newcommand{\ccol}[1]{\omit\ensuremath{\hfill #1\hfill}}
\begin{document}
    \begin{alignat}{5}
        &\ccol{M \ddot x}
        && + &
        \ccol{D_s \dot x}
        && + &
        \ccol{K x}
        && = &
        \ccol{F \cos(\omega t + \delta)}
        && + &
        \ccol{P \cos(\gamma) \label{eq1}} \\[6pt]
        %
        &\ccol{\underset{\substack{\text{сила} \\ \text{инерции}}}{M \ddot y}} && + &
        \ccol{\underset{\substack{\text{сила} \\ \text{вязкого} \\ \text{трения}}}{D_s \dot y}}  && + &
        \ccol{\underset{\substack{\text{сила} \\ \text{упругости}}}{K y}} && = &
        \ccol{\underset{\substack{\text{внешняя} \\ \text{вращающаяся} \\ \text{возбуждающая} \\ \text{сила}}}{F \sin(\omega t + \delta)}} && + &
        \underset{\substack{\text{постоянная} \\ \text{радиальная} \\ \text{сила} \\ \text{нагружения}}}{P \sin(\gamma)} \label{eq2}
    \end{alignat}
\end{document}
Stefan
Surprisingly, I was so close to correct answer! :shock: Many thanks, Stefan!

I'd like to clarify post header. How can I do it?
User avatar
Stefan Kottwitz
Site Admin
Posts: 10290
Joined: Mon Mar 10, 2008 9:44 pm

Command \ref don't work correctly

Post by Stefan Kottwitz »

You can edit your first post, that has the header. Otherwise, if it's restricted/protected and cannot be edited after some time, you can just let me know and I edit it for you, I can edit the post headers.

Stefan
LaTeX.org admin
Post Reply