Alterning images in beamer is shifting to right - image

When I am trying to do alternating images in beamer with usage of the \only and overlayarea like this:
\begin{frame}
\frametitle{Tasks}
\begin{overlayarea}{\textwidth}{\textheight}
\begin{figure}
\centering
\only<1>
{
\includegraphics[width=0.3\textwidth]{img/noise_detail_2.png}
}
\only<2>
{
\includegraphics[width=0.3\textwidth]{img/noise_detail_2.png}
}
\only<3>
{
\includegraphics[width=0.3\textwidth]{img/noise_detail_2.png}
}
\only<4>
{
\includegraphics[width=0.3\textwidth]{img/noise_detail_2.png}
}
\end{figure}
\end{overlayarea}
\end{frame}
the image is moving to the right more and more on the each slide. Let's say, that in the 1. slide is in the position x, in the second slide in the position x+5 and in the third slide x+10.
Why? How can I fix it?

You have what is referred to as a spurious space between usages of \only. While spreading out your code for readability purposes might work well, sometimes these spaces cause unwanted output in your resulting PDF. Use % to keep the readability but avoid the spacing issues:
\documentclass{beamer}
\begin{document}
\begin{frame}
\frametitle{Tasks}
\begin{overlayarea}{\textwidth}{\textheight}
\begin{figure}
\centering
\only<1>
{%
\includegraphics[width=.8\textwidth]{example-image-a}%
}%
\only<2>
{%
\includegraphics[width=.8\textwidth]{example-image-b}%
}%
\only<3>
{%
\includegraphics[width=.8\textwidth]{example-image-c}%
}%
\end{figure}
\end{overlayarea}
\end{frame}
\end{document}

Related

Subfigures in latex never shrinks to be on one row (pfd file)

I'm trying to adjust two subfigures into one row. This is my code:
\begin{figure}[ht]
\centering
\caption{Migration rates and nightlights in Albania in 1992-1995}
\begin{subfigure}[a]{0.3\textwidth}
\caption{Emigration rate before 1995 at the municipality level}
\label{fig: migration_rate}
\includegraphics[width=\linewidth, trim = 5cm 0cm 5cm 0cm, clip]{Figures/migration_rate.pdf}
\end{subfigure}
\begin{subfigure}[b]{0.3\textwidth}
\caption{Night luminosity in 1992}
\label{fig: nighlights}
\includegraphics[width=\linewidth, trim = 5cm 0cm 5cm 0cm, clip]{Figures/nightlight.pdf}
\end{subfigure}
\caption*{\footnotesize{\textbf{Notes}:}}.
\end{figure}
enter image description here
Even if I shrink the subfigure to tiny size (for example {0.01\textwidth}), the two always appear in one column. I have deep blank space on the left and right of both figures that I have tried to trim. Including or excluding "trim" does not change much.
How do I get the two into one row?
Thank you!

Center image in overleaf with margins instead of text

I'm trying to center an image in the middle of the page in overleaf, but all the centering functions I can find only seem to center it in terms of the text, not the margins of the whole document. Is there a way to align an image to the center of the page, not aligned with the text? It ends up being a bit skewed to the right as is.
Here is the code for inserting my image:
\begin{figure}[H]
\centering
\includegraphics[width=1.1\textwidth, height = 1.5cm]{s_TTCD_data.png}
\caption{Tongue tip constriction location (TTCL) data for /s/.}
\end{figure}
I've also tried this, with the same result:
\begin{center}
\begin{figure}[H]
\includegraphics[width=1.1\textwidth, height = 1.5cm]{s_TTCD_data.png}
\caption{Tongue tip constriction location (TTCL) data for /s/.}
\end{figure}
\end{center}
Try:
\begin{figure}[H]
\centerline{\includegraphics[width=1.1\textwidth, height = 1.5cm]{s_TTCD_data.png}}
\caption{Tongue tip constriction location (TTCL) data for /s/.}
\end{figure}

Generate equations with label in sharelatex

I have made the following equation in sharelatex:
\[ \frac{\delta u}{\delta x} + \frac{\delta v}{\delta y} = 0 \]
How can I automatically label this equation with a number?
I have the following before the beginning of my document. My code is a bit messy, but I hope it can show what the problem is that prevents equation from working.
How can I automatically label this equation with a number?
I have the following before the beginning of my document. My code is a bit messy, but I hope it can show what the problem is that prevents equation from working.
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{nomencl}
\makenomenclature
\usepackage[english]{babel}
\usepackage[round]{natbib}
\usepackage{natbib}
\setcitestyle{square}
\usepackage[utf8]
\usepackage[table, svgnames, dvipsnames]{xcolor} %color row
\usepackage{makecell}
\renewcommand\theadfont{\normalsize}
\usepackage{caption}
\usepackage{siunitx}
\usepackage[justification=centering,font=small,labelfont=bf,tableposition=top]{caption}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[bottom]{footmisc}
\usepackage[margin=1.1in]{geometry}
\geometry{a4paper,total={170mm,257mm},left=22mm,right=22mm,top=30mm,bottom=20mm}
\usepackage{booktabs}
\usepackage[numbers]{natbib}
\usepackage{float}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{array}
\usepackage{blindtext}
\usepackage{color}
\usepackage{comment}
\usepackage{fancyhdr}
\usepackage{float}
\usepackage{footnote}
\usepackage{gensymb}
\usepackage{graphicx}
\usepackage{graphics}
\usepackage{hyperref}
\usepackage{lastpage}
\usepackage{listings}
\usepackage{longtable}
\usepackage{nomencl}
\usepackage{pifont}
\usepackage{subcaption}
\usepackage{subfiles}
\usepackage{tablefootnote}
\usepackage{times}
\usepackage{tikz}
\usepackage{watermark}
\usepackage{pdfpages}
\usepackage[pdftex]{graphicx}
\usepackage{graphicx,subcaption}
%for the tables
\usepackage[margin=1in,letterpaper]{geometry} % text block parameters
\usepackage{tabularx,siunitx,booktabs}
\usepackage[skip=0.5\baselineskip]{caption}
\usepackage{newtxtext,newtxmath}
\newcommand\mX[1]{\multicolumn{1}{X}{#1}} % handy shortcut macros
\newcommand\mcc[1]{\multicolumn{2}{c}{#1}}
\newcommand\mcl[1]{\multicolumn{2}{l}{#1}}\usepackage[margin=1in,letterpaper]{geometry} % text
\usepackage{multirow}
\graphicspath{{./Figures/}}
\setlength\parindent{0pt}
\usetikzlibrary{arrows,calc,positioning,shadows,shapes}
\newcommand{\cmark}{\textcolor{green!80!black}{\ding{51}}}
\newcommand{\xmark}{\textcolor{red}{\ding{55}}}
\usepackage{enumitem}%make indented dots
\usepackage{textcomp}
\usepackage{amsmath}
% Array commands, depends on \usepackage{array}
\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}}
% Something with captions, depends on \usepackage{caption}
\DeclareCaptionLabelFormat{andtable}{#1~#2 \& \tablename~\thetable}
% Front page settings depends on \usepackage{fancyhdr}
\pagestyle{fancy}
\lhead{Name}
\newcommand{\specialcell}[2][c]{%
\begin{tabular}[#1]{#{}c#{}}#2\end{tabular}}
\rhead{Project}
\renewcommand{\baselinestretch}{1.3} % Line spacing
% Color settings depends on \usepackage{color}
\definecolor{mygreen}{RGB}{28,172,0} % color values Red, Green, Blue
\definecolor{mylilas}{RGB}{170,55,241}
\begin{document}
I have tried several codes but nothing is working. Not even the equation option.
Thanks for help in advance!
There are several serve errors in your preamble. You must fix them, if you ignore them tex only syntax checks the rest of the document and you end up with something that might or might not be a valid pdf
you must not load the same package multiple times with different options. The log file will clearly tell you about the error because of an option clash. In your example this concerns geometry, graphicx and natbib
the line \usepackage[utf8] is an syntax error. You must give a package name, not just an option
many other packages are loaded multiple times and some of the options are outdated, you should take a bit of time and clean up this preamble
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{nomencl}
\makenomenclature
\usepackage[english]{babel}
\usepackage[round]{natbib}
%\usepackage{natbib}
\setcitestyle{square}
%\usepackage[utf8]
\usepackage[table, svgnames, dvipsnames]{xcolor} %color row
\usepackage{makecell}
\renewcommand\theadfont{\normalsize}
\usepackage{caption}
\usepackage{siunitx}
\usepackage[justification=centering,font=small,labelfont=bf,tableposition=top]{caption}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[bottom]{footmisc}
\usepackage[margin=1.1in]{geometry}
\geometry{a4paper,total={170mm,257mm},left=22mm,right=22mm,top=30mm,bottom=20mm}
\usepackage{booktabs}
%\usepackage[numbers]{natbib}
\usepackage{float}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{array}
\usepackage{blindtext}
\usepackage{color}
\usepackage{comment}
\usepackage{fancyhdr}
\usepackage{float}
\usepackage{footnote}
\usepackage{gensymb}
\usepackage{graphicx}
\usepackage{graphics}
\usepackage{hyperref}
\usepackage{lastpage}
\usepackage{listings}
\usepackage{longtable}
\usepackage{nomencl}
\usepackage{pifont}
\usepackage{subcaption}
\usepackage{subfiles}
\usepackage{tablefootnote}
\usepackage{times}
\usepackage{tikz}
\usepackage{watermark}
\usepackage{pdfpages}
%\usepackage[pdftex]{graphicx}
%\usepackage{graphicx,subcaption}
%for the tables
%\usepackage[margin=1in,letterpaper]{geometry} % text block parameters
\usepackage{tabularx,siunitx,booktabs}
\usepackage[skip=0.5\baselineskip]{caption}
\usepackage{newtxtext,newtxmath}
\newcommand\mX[1]{\multicolumn{1}{X}{#1}} % handy shortcut macros
\newcommand\mcc[1]{\multicolumn{2}{c}{#1}}
\newcommand\mcl[1]{\multicolumn{2}{l}{#1}}
%\usepackage[margin=1in,letterpaper]{geometry} % text
\usepackage{multirow}
\graphicspath{{./Figures/}}
\setlength\parindent{0pt}
\usetikzlibrary{arrows,calc,positioning,shadows,shapes}
\newcommand{\cmark}{\textcolor{green!80!black}{\ding{51}}}
\newcommand{\xmark}{\textcolor{red}{\ding{55}}}
\usepackage{enumitem}%make indented dots
\usepackage{textcomp}
\usepackage{amsmath}
% Array commands, depends on \usepackage{array}
\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}}
% Something with captions, depends on \usepackage{caption}
\DeclareCaptionLabelFormat{andtable}{#1~#2 \& \tablename~\thetable}
% Front page settings depends on \usepackage{fancyhdr}
\pagestyle{fancy}
\lhead{Name}
\newcommand{\specialcell}[2][c]{%
\begin{tabular}[#1]{#{}c#{}}#2\end{tabular}}
\rhead{Project}
\renewcommand{\baselinestretch}{1.3} % Line spacing
% Color settings depends on \usepackage{color}
\definecolor{mygreen}{RGB}{28,172,0} % color values Red, Green, Blue
\definecolor{mylilas}{RGB}{170,55,241}
\begin{document}
\begin{equation}
\frac{\delta u}{\delta x} + \frac{\delta v}{\delta y} = 0
\end{equation}
\end{document}

Images not showing up in PDF compile of thesis in Latex (via Overleaf)

I have images inside a figures folder for my thesis. When I use the \includegraphics[]{} command in my chapterX.tex file, the image just won't appear (in normal mode, fast mode, or in the downloaded PDF). They seem to scale, but just won't appear.
I've tried using the graphicsx and graphics packages, but neither work.
\documentclass[
10pt,
english,
singlespacing,
draft,
parindent 20mm
headsepline,
chapterinoneline,
]{MastersDoctoralThesis}
\usepackage[utf8]{inputenc}
\usepackage{ctable}
\usepackage[T1]{fontenc}
\usepackage{minitoc}
\setcounter{minitocdepth}{2}
\setlength{\mtcindent}{24pt}
\usepackage{hyperref}
\hypersetup{
colorlinks=true,
linkcolor=blue,
filecolor=magenta,
urlcolor=cyan,
}
\usepackage{enumitem}
\setlist[itemize]{noitemsep}
\setlist[enumerate]{noitemsep}
\usepackage{graphicx} % Required for including images
\graphicspath{{figures/}} % Location of the graphics files
\geometry{
paper=a4paper, % Change to letterpaper for US letter
inner=3cm, % Inner margin
outer=3cm, % Outer margin
%bindingoffset=.5cm, % Binding offset
top=1.5cm, % Top margin
bottom=1.5cm, % Bottom margin
%showframe, % Uncomment to show how the type block is set on the page
}
\begin{document}
\chapter{Conceptual framework}
\label{Chapter3}
\minitoc
\section{Introduction}
Below is Jackendoff's parallel architecture.
\includegraphics{figures/jackendoffpa.jpeg}
You need to remove the draft option to see your images:
\documentclass[
10pt,
english,
singlespacing,
%draft,
parindent 20mm
headsepline,
chapterinoneline,
]{MastersDoctoralThesis}
\usepackage[utf8]{inputenc}
\usepackage{ctable}
\usepackage[T1]{fontenc}
\usepackage{minitoc}
\setcounter{minitocdepth}{2}
\setlength{\mtcindent}{24pt}
\usepackage{hyperref}
\hypersetup{
colorlinks=true,
linkcolor=blue,
filecolor=magenta,
urlcolor=cyan,
}
\usepackage{enumitem}
\setlist[itemize]{noitemsep}
\setlist[enumerate]{noitemsep}
\usepackage{graphicx} % Required for including images
\graphicspath{{figures/}} % Location of the graphics files
\geometry{
paper=a4paper, % Change to letterpaper for US letter
inner=3cm, % Inner margin
outer=3cm, % Outer margin
%bindingoffset=.5cm, % Binding offset
top=1.5cm, % Top margin
bottom=1.5cm, % Bottom margin
%showframe, % Uncomment to show how the type block is set on the page
}
\begin{document}
\chapter{Conceptual framework}
\label{Chapter3}
\minitoc
\section{Introduction}
Below is Jackendoff's parallel architecture.
\includegraphics{jackendoffpa}
\end{document}

Image numbering depending on the partition number in which the image is displayed

How can I make captions under images in Fig. 1.1:, Fig. 1.2:, Fig. 2.1:, Fig. 2.2: depending on the section number and not just sequentially from 1 for all images in the article
For example code:
\begin{figure}[htbp]
\minipage{0.32\textwidth}
\centering\includegraphics[width=\linewidth]{images/1.png}
\caption{caption 1}\label{Fig_1}
\endminipage\hfill
\minipage{0.32\textwidth}%
\centering\includegraphics[width=\linewidth]{images/2.png}
\caption{caption 2}\label{Fig_2}
\endminipage\hfill
\minipage{0.32\textwidth}%
\centering\includegraphics[width=\linewidth]{images/3.png}
\caption{caption 3}\label{Fig_3}
\endminipage
\end{figure}
Without any additional packages, latex itself provides the macro \counterwithin which allows to number the figures on a per section basis:
\documentclass{article}
\usepackage{graphicx}
\counterwithin{figure}{section}
\begin{document}
\section{title}
\begin{figure}[htbp]
\begin{minipage}{0.32\textwidth}
% \centering
\includegraphics[width=\linewidth]{example-image-duck}
\caption{caption 1}
\label{Fig_1}
\end{minipage}
\hfill
\begin{minipage}{0.32\textwidth}%
% \centering
\includegraphics[width=\linewidth]{example-image-duck}
\caption{caption 2}
\label{Fig_2}
\end{minipage}
\hfill
\begin{minipage}{0.32\textwidth}%
% \centering
\includegraphics[width=\linewidth]{example-image-duck}
\caption{caption 3}
\label{Fig_3}
\end{minipage}
\end{figure}
\end{document}
(\centering is not necessary if the images already have the same width as the minipage)
There is an answer to this question in tex.stackechange https://tex.stackexchange.com/questions/28333/continuous-v-per-chapter-section-numbering-of-figures-tables-and-other-docume
It redefines counters with the chngcntr package.
But in my opinion, the simpler is to use the floatpackage. It allows to redefine floating environments, with a specific graphic appearance, position, etc, and numbering scheme.
\documentclass{article}
\usepackage{graphicx}
\usepackage{float}
% We define a new float environment called image.
% htbp means 'images' will be positioned preferably here, then at top, bottom or
% on a new page
% info on labels will go to file xx.lim (list of images)
% and it will numbered within sections
\newfloat{image}{htbp}{lim}[section]
% and we want 'Fig.' to appear on the caption
\floatname{image}{Fig.}
\begin{document}
\section{A first section}
blah blah. Look at image \ref{im1}. blah blah
\begin{image}
\centering
\includegraphics[width=3cm]{example-image}
\caption{An image}\label{im1}
\end{image}
\section{A second section}
blah blah. And now consider images \ref{im2} and \ref{im3}. blah blah
\begin{image}
\centering
\hfill\includegraphics[width=3cm]{example-image}\hfill\includegraphics[width=3cm]{example-image}\hfill\includegraphics[width=3cm]{example-image}\hfill
\caption{Now a bunch with several images}\label{im2}
\end{image}
blah blah
\begin{image}
\centering
\begin{tabular}{cc}
\includegraphics[width=3cm]{example-image} &\includegraphics[width=3cm]{example-image}\\
Image A&Image B
\end{tabular}
\caption{And two last images}\label{im3}
\end{image}
\end{document}
If you have several images in a fig, just place them as any text. In TeX, images are considered as (large) characters and the standard positioning methods apply. In the first example, I used \hfill to spread them evenly on a line, and in the second a tabular to include small comments on the images. But many other methods, like minipages, can be used. But if your image set is too long to fit on a line, unwanted line breaks may appear.
Unrelated, but any people use the float package because it also defines a new placement directive 'H' that means more or less 'place the float Here and nowhere else'. And modifying the graphics appearance of floats is also very useful.
Here is another solution without the float package
\documentclass{article}
\usepackage{graphicx}
\usepackage{chngcntr}
% change counter numbering
\counterwithin{figure}{section}
\begin{document}
\section{A first section}
blah blah. Look at images \ref{im1}, \ref{im2} and \ref{im3}. blah blah
\begin{figure}[h]
\begin{minipage}{0.3\linewidth}
\centering
\includegraphics[width=\linewidth]{example-image}
\caption{image 1}\label{im1}
\end{minipage}
\hfill
\begin{minipage}{0.3\linewidth}
\centering
\includegraphics[width=\linewidth]{example-image}
\caption{image 2}\label{im2}
\end{minipage}
\hfill
\begin{minipage}{0.3\linewidth}
\centering
\includegraphics[width=\linewidth]{example-image}
\caption{image 3}\label{im3}
\end{minipage}
\centering
\end{figure}
\end{document}

Resources