1

I need to make tables and images with captions on right of them. I've tried:

\usepackage[rightcaption]{sidecap}
...
a
\begin{SCfigure}[0.5][h]
    \caption{Caption}
    \includegraphics[width=0.6\textwidth]{plot}
\end{SCfigure}
b
\begin{SCtable}
    \begin{tabular}{ |c|c| } 
        \hline
        $x$ & $C(x)$ \\
        \hline
        0.0 & 0.0 \\
        0.15 & 0.1499812631728948 \\
        0.3 & 0.2994004215326338 \\
        0.45 & 0.4454682784363537 \\
        0.6 & 0.5810954378649809 \\
        0.75 & 0.6935255871549416 \\ 
        0.9 & 0.7648231512442959 \\
        1.05 & 0.7759094586072925 \\
        1.2 & 0.7154377656829878 \\
        1.35 & 0.5922667102368842 \\
        1.5 & 0.4452612215631238 \\
        \hline
    \end{tabular}
    \caption{Caption}
\end{SCtable}
c

But I've got:

Wrong result

The captions are in right places, but 'a', 'b' and 'c' are not. How can I fix this?

I want a result like:

a

image, caption

b

table, caption

c

Full code

\documentclass[a4paper,14pt]{extarticle}
\usepackage[left=2.5cm, right=2.5cm, bottom=2.5cm, top=2.5cm]{geometry}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[russian]{babel}
\usepackage{hyperref}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{slashbox}
\usepackage[rightcaption]{sidecap}

\usepackage{listings}
\usepackage{color}
\definecolor{codegreen}{rgb}{0,0.6,0}
\definecolor{codegray}{rgb}{0.5,0.5,0.5}
\definecolor{codepurple}{rgb}{0.58,0,0.82}
\definecolor{backcolour}{rgb}{0.95,0.95,0.92}
\lstdefinestyle{mystyle}{
    backgroundcolor=\color{backcolour},   
    commentstyle=\color{codegreen},
    keywordstyle=\color{magenta},
    numberstyle=\tiny\color{codegray},
    stringstyle=\color{codepurple},
    basicstyle=\footnotesize,
    breakatwhitespace=false,         
    breaklines=true,                 
    captionpos=b,                    
    keepspaces=true,                 
    numbers=left,                    
    numbersep=5pt,                  
    showspaces=false,                
    showstringspaces=false,
    showtabs=false,                  
    tabsize=2
}
\lstset{style=mystyle}

\graphicspath{ {./images/} }
\makeatletter
\setlength{\@fptop}{0pt}
\makeatother
\begin{document}
\begin{titlepage}
    \centering
    {\scshape\LARGE Казанский (Приволжский) федеральный университет \par}
    \vspace{1cm}
    {\scshape\Large Курсовой проект по численным методам\par}
    \vspace{1.5cm}
    {\huge\bfseries Табулирование трансцендентных функций\par}
    \vspace{2cm}
    {\Large\itshape Тазетдинов Р.И.\par}
    \vfill
    проверила\par
    Гнеденкова В.Л.

    \vfill

    % Bottom of the page
    {\large 2019 г.}
\end{titlepage}
\tableofcontents
\newpage
\section{Постановка задачи}
Одна из специальных функций математической физики -- интеграл Френеля, определяется следующим образом
$$
C(x)=\int_{0}^{x} \cos \left(\frac{\pi t^{2}}{2}\right) d t
$$
Цель задания -- изучить и сравнить различные способы приближенного вычисления этой функции.

Будем проводить следующие вычисления:
\begin{itemize}
    \item Протабулируем $C(x)$ на  отрезке $[0,1.5]$ с шагом $0.15$ и точностью $10^{-6}$, основываясь на ряде Тейлора
    \item По полученной таблице значений построим интерполяционный полином Лагранжа
    $$
    L_{n}(x)=\sum_{i=0}^{n} f\left(x_{i}\right) \prod_{i \neq j \atop j=0}^{n} \frac{x-x_{j}}{x_{i}-x_{j}}
    $$ и вычислим погрешность интерполирования
    $$
    \varepsilon_{n}=\max _{x \in(a, b)} \varepsilon(x), \quad \varepsilon(x)=\left|C(x)-L_{n}(x)\right|
    $$
    \item На той же сетке узлов $\left\{x_{i}\right\}_{i=0}^{n}$ построим таблицу приближенных значений $C(x)$, используя составную формулу
    $$
    \int_{c}^{d} \varphi(t) d t=\sum_{i=1}^{N} \int_{z_{i-1}}^{z_{i}} \varphi(t) d t \approx \sum_{i=1}^{N} S_{i}(\varphi)
    $$
    где $z_i$ -- точки разбиения отрезка интегрирования на $N$ частей, $z_{i}=c+i \cdot h_{N}$,  $h_{N}=\frac{d-c}{N}$.
    \item Построим таблицу обратной к $C(x)$ функции $F=C^{-1}$ решая уравнения 

    $$
    C(z)=F_{i}, \quad i=0, \ldots, n, \quad F_{i}=f_{0}+i \cdot \frac{f_{n}-f_{0}}{n}
    $$ 

    при  $g(z)=0$
\end{itemize}
\newpage
\section{Ряд Тейлора}
Функция интегрального косинуса не может быть представлена через элементарные функции, но, разлагая интегрируемое выражение исходной функции в ряд Тейлора и интегрируя почленно, мы можем получить её представление в виде ряда:
\begin{align*}
C(x)&=\int_0^x\cos\left(\frac{\pi t^2}2\right)\mathrm dt=\int_0^x\sum_{n=0}^\infty(-1)^n\frac{\left(\frac{\pi t^2}2\right)^{2n}}{(2n)!}\mathrm dt=\sum_{n=0}^\infty(-1)^n\frac{\left(\frac\pi2\right)^{2n}}{(2n)!}\int_0^xt^{4n}\mathrm dt\\
&=\sum_{n=0}^\infty(-1)^n\frac{\left(\frac\pi2\right)^{2n}}{(2n)!}\left[\frac{t^{4n+1}}{4n+1}\right]_0^x=\sum_{n=0}^{\infty} \frac{(-1)^{n}\left(\frac{\pi}{2}\right)^{2 n}}{(2 n) !(4 n+1)} x^{4 n+1}
\end{align*}
Изучим сходимость ряда. Так как ряд является степенным, по признаку Даламбера, мы можем вычислить радиус его сходимости следующим способом:
$$
R=\lim _{n \rightarrow \infty}\left|\frac{a_{n}}{a_{n+1}}\right|,
$$
где $a_n$ -- это коэффициент степенного ряда с номером $n$.
Имеем
$$
\lim _{n \rightarrow \infty}\left|\frac{a_{n}}{a_{n+1}}\right|=\lim _{n \rightarrow \infty}\left|\frac{(2 n+2) !(4 n+5)}{(2 n) !(4 n+1)}\right|=\lim _{n \rightarrow \infty}\left|\frac{(2 n+1)(2 n+2)(4 n+5)}{4 n+1}\right|=\infty
$$
Таким образом область сходимости -- вся числовая прямая и мы можем табулировать его на любом отрезке.

Заметим, что, при вычислении ряда Тейлора $\sum_{n=0}^{\infty} a_{n}$, каждый последующий член ряда $a_{n+1}$ получается из предыдущего члена $a_n$ умножением на некоторую величину $q_n$, то есть $a_{n+1} = a_n \cdot q_n$. Это позволяет избежать переполнения при вычислении факториалов, встречающихся в рассматриваемом ряде.

Вычислим $q_n$ для нашего ряда Тейлора, чтобы применить его при вычислении

$$
\frac{(-1)^{n}\left(\frac{\pi}{2}\right)^{2 n}}{(2 n) !(4 n+1)} x^{4 n+1} \cdot q_{n}=\frac{(-1)^{n+1}\left(\frac{\pi}{2}\right)^{2 n+2}}{(2 n+2) !(4 n+5)} x^{4 n+5} \Longleftrightarrow
$$

$$
q_{n}=\frac{(-1)^{n+1}\left(\frac{\pi}{2}\right)^{2 n}}{(-1)^{n}\left(\frac{\pi}{2}\right)^{2 n+2}} \cdot \frac{(2 n) !(4 n+1)}{(2 n+2) !(4 n+5)} \cdot \frac{x^{4 n+5}}{x^{4 n+1}} \Longleftrightarrow
$$

$$
q_{n}=-x^{4}\left(\frac{\pi}{2}\right)^{2} \frac{4 n+1}{(2 n+2)(2 n+1)(4 n+5)}
$$.
a

\begin{SCfigure}[0.5][h]
        \centering
        \includegraphics[width=0.6\textwidth]{plot}
        \caption{Caption}
\end{SCfigure}

b

\begin{SCtable}
    \centering
    \begin{tabular}{ |c|c| } 
        \hline
        $x$ & $C(x)$ \\
        \hline
        0.0 & 0.0 \\
        0.15 & 0.1499812631728948 \\
        0.3 & 0.2994004215326338 \\
        0.45 & 0.4454682784363537 \\
        0.6 & 0.5810954378649809 \\
        0.75 & 0.6935255871549416 \\ 
        0.9 & 0.7648231512442959 \\
        1.05 & 0.7759094586072925 \\
        1.2 & 0.7154377656829878 \\
        1.35 & 0.5922667102368842 \\
        1.5 & 0.4452612215631238 \\
        \hline
    \end{tabular}
    \caption{Caption}
\end{SCtable}

c
\begin{SCtable}
    \begin{tabular}{ |c|c|c|c|c|c|c|c|c|c|c|c| } 
        \hline
        \backslashbox{$\varepsilon$}{$n$} & 0.0 & 0.15 & 0.3 & 0.45 & 0.6 & 0.75 & 0.9 & 1.05 & 1.2 & 1.35 & 1.5 \\
        \hline
        $10^{-6}$ & 0 &  1 &  1  & 2  & 3  & 3  & 4  & 5  & 6  & 7  & 8 \\
        $10^{-7}$  & 0  & 1  & 2  & 2  & 3  & 4  & 5  & 5  & 6  & 7  & 8 \\
        $10^{-8}$  & 0  & 1  & 2 &  3 &  3 &  4  & 5  & 6  & 7 &  8  & 9 \\
        $10^{-9}$ &  0  & 2 &  2 &  3 &  4 &  5 &  6  & 6  & 7  & 8  & 10 \\ 
        $10^{-10}$  & 0  & 2 &  3 &  3 &  4 &  5 &  6 &  7 &  8 &  9 &  10 \\
        \hline
    \end{tabular}
    \caption{Caption}
\end{SCtable}

\end{document}
jGaboardi
  • 502
  • 1
    from code fragment, which you show, wen't see, what is going on in your document. in normal circumstances this should work. please, extend your code snippet to complete small document, which exhibits your problem. – Zarko May 12 '19 at 21:14
  • @Zarko Sure, https://pastebin.com/aj2CFu7h –  May 12 '19 at 21:22
  • 1
    no in "pastbin", in question please. after while it will not be accessible and other people will not able to know, what have been your problem. – Zarko May 12 '19 at 21:25
  • 1
    what is meaning of "a", "b " and " c"? what is their purpose? where you like to have? they flow away because between the is not enough space for your figure and tables. try add \clearpage before "a" and tell us, if this solve your problem. your example have more issues: istead $$> you should use \[ and \] (or \begin{equation*}, `\end{equation*}, second table is to wide that can be fit in text area, etc. – Zarko May 12 '19 at 22:21

1 Answers1

0

I think maybe you just needed line breaks after your text.


For tables below text:

\documentclass{article}
\usepackage[rightcaption]{sidecap}

\begin{document}

a

\begin{SCtable}[0.5][h]
    \begin{tabular}{ |c|c| } 
        \hline
        $x$ & $C(x)$ \\
        \hline
        0.0 & 0.0 \\
        0.15 & 0.1499812631728948 \\
        \hline
    \end{tabular}
    \caption{Caption}
\end{SCtable}

b

\begin{SCtable}[0.5][h]
    \begin{tabular}{ |c|c| } 
        \hline
        $x$ & $C(x)$ \\
        \hline
        1.35 & 0.5922667102368842 \\
        1.5 & 0.4452612215631238 \\
        \hline
    \end{tabular}
    \caption{Caption}
\end{SCtable}

c

\begin{SCtable}[0.5][h]
    \begin{tabular}{ |c|c| } 
        \hline
        $x$ & $C(x)$ \\
        \hline
        0.75 & 0.6935255871549416 \\ 
        0.9 & 0.7648231512442959 \\
        \hline
    \end{tabular}
    \caption{Caption}
\end{SCtable}
\end{document}

enter image description here


For text below tables:

\documentclass{article}
\usepackage[rightcaption]{sidecap}

\begin{document}

\begin{SCtable}[0.5][h]
    \begin{tabular}{ |c|c| } 
        \hline
        $x$ & $C(x)$ \\
        \hline
        0.0 & 0.0 \\
        0.15 & 0.1499812631728948 \\
        \hline
    \end{tabular}
    \caption{Caption}
\end{SCtable}

a

\begin{SCtable}[0.5][h]
    \begin{tabular}{ |c|c| } 
        \hline
        $x$ & $C(x)$ \\
        \hline
        1.35 & 0.5922667102368842 \\
        1.5 & 0.4452612215631238 \\
        \hline
    \end{tabular}
    \caption{Caption}
\end{SCtable}

b

\begin{SCtable}[0.5][h]
    \begin{tabular}{ |c|c| } 
        \hline
        $x$ & $C(x)$ \\
        \hline
        0.75 & 0.6935255871549416 \\ 
        0.9 & 0.7648231512442959 \\
        \hline
    \end{tabular}
    \caption{Caption}
\end{SCtable}

c

\end{document}

enter image description here

jGaboardi
  • 502
  • Now 'a', 'b' and 'c' are in the bottom... –  May 12 '19 at 21:07
  • The code above compiles to provide the exact image above. Simply placing the a, b, and c below the tables will provide the result you desire. – jGaboardi May 12 '19 at 21:15