I am trying to add a simple figure into my latex code .I have this code :
\begin{figure}[H]
\resizebox{40pt}{!}{
\centering \includegraphics{FigureStereo.jpg}}
\caption{Epipolar Geometry}
\label{fig:cclogo}
\end{figure}
with this however the text comes on top of the image and also image is not centered .What am I doing wrong?Hopefully this is not a repeated question coz I did do a quick check on related posts.
Edited
Here is the preamble
\documentclass[draftthesis,tocnosub,noragright,centerchapter,12pt,]{uiucecethesis09}
\makeatletter
\usepackage{setspace}
\usepackage{epsfig} % for figures
\usepackage{graphicx} % another package that works for figures
%\usepackage{subfigure} % for subfigures
\usepackage{amsmath} % for math spacing
%\usepackage{amssymb} % for math spacing
%\usepackage{url} % Hyphenation of URLs.
\usepackage{lscape} % Useful for wide tables or figures.
\usepackage[justification=raggedright]{caption} % makes captions ragged right - thanks to Bryce Lobdell
\usepackage{float}
\usepackage{wrapfig}
% Uncomment the appropriate one of the following four lines:
\msthesis
%\phdthesis
%\otherdoctorate[abbrev]{Title of Degree}
%\othermasters[abbrev]{Title of Degree}
\title{}
\author{}
\department{}
\degreeyear{}
% Advisor name is required for
% - doctoral students for the ProQuest abstract
% - master's students who do not have a master's committee
\advisor{}
% Uncomment the \committee command for
% - all doctoral students
% - master's students who have a master's committee
%\committee{Professor Firstname Lastname, Chair\\
% Professor Firstname Lastname} % etc.
You can use a center environment for centering, wrapping it around both the image box and the caption:
\begin{figure}[h!]
\begin{center}
\resizebox{40pt}{!}{\includegraphics{FigureStereo.jpg}}
\caption{Epipolar Geometry}
\label{fig:cclogo}
\end{center}
\end{figure}
Note, though, that LaTeX can sometimes be pretty stubborn about how it lays out pages where floating elements are concerned. The h option is more of a guideline than a guarantee. In some cases you might be better off not using a floating figure environment and instead inserting the graphics and text directly.
Also, you're better off asking this sort of question over at the TeX StackExchange site.
You probably just want something like
\begin{figure}[t]
\centerline{\includegraphics[width=\columnwidth]{figs/foo}}
\caption{Caption Goes Here}
\label{fig:cclogo}
\end{figure}
Related
I'm new to LaTex and I wanted to know how I can change the Margins of my scrreport so that the chapter title, text and basically everythin starts a bit higher and ends a bit lower. In my opinion there is too much empty space before anything starts.
If I use this simple example:
\documentclass[12pt,a4paper,twoside]{scrreport}
\usepackage{blindtext}
\begin{document}
\chapter{First Chapter}
\blindtext
\end{document}
I think the margins from top and bottom are too big. So i want everything to move up a little bit.
Thanks!
Method 1:
Choose one of the predefined layouts. You'll find a list of available options in the koma script documentation.
\documentclass[12pt,a4paper,twoside,DIV=15]{scrreport}
\usepackage{blindtext}
\begin{document}
\chapter{First Chapter}
\blinddocument
\end{document}
Method 2:
Setting up the text area manually. You should be really sure that you know what you are doing to get an aesthetically pleasant result.
\documentclass[12pt,a4paper,twoside]{scrreport}
\areaset[current]{168.00mm}{250mm}
\usepackage{blindtext}
\begin{document}
\chapter{First Chapter}
\blinddocument
\end{document}
I am using the \twocolumn tag to use the two-column layout in LaTeX. The problem is that this does not work properly and the text seems not to be fixed between the borders. Not sure if that minimal example helps, but at least you can see my includes and the text with which it happens.
\documentclass[12pt,a4paper, abstracton]{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage[backend=biber, sorting=none]{biblatex}
\usepackage{hyperref}
\usepackage[hyphenbreaks]{breakurl}
\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}
\begin{document}
\twocolumn
\section{Introduction}
Glutamate carboxypeptidase II (GCPII), N-acetyl-L-aspartyl-L-glutamate peptidase I (NAALADase I), NAAG peptidase or prostate-specific membrane antigen (PSMA) \dots
\end{document}
Screenshot of left column in PDF that shows the problem
Why does LaTeX write from the first column into the second column and how can I fix that? I would like to avoid change each line separately, where that happens. I am looking for a global solution.
Since the workarounds of the accepted answer were not satisfactory to me, I kept searching and found a more adequate and fast workaround, adding to my preamble the following:
\setlength{\emergencystretch}{3em}
The length 3em can be changed as needed, just keep it as low as possible in order to preserve optimal appearance.
More details here.
Latex has trouble finding a suitable break point because words with multiple capital letters are normally assumed to be acronyms which should not be hyphenated.
Possible workarounds:
force a line break with \linebreak before the word. This might result in undesirable large spaces in the line, especially in your situation in with only a single white space in the line
tell latex where possible break points are with long\-word (I don't know if there are any possible hyphenation points in NAALADase). This can also be globally for the whole document with \hyphenation{long-word} in your preamble
rephrase the sentence
use another layout. Very short lines combined with very long and unbreakable words is a tough combination
\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage[backend=biber, sorting=none]{biblatex}
\usepackage{hyperref}
\usepackage[hyphenbreaks]{breakurl}
\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}
\begin{document}
\twocolumn
\section{Introduction}
Glutamate carboxypeptidase II (GCPII), N-acetyl-L-aspartyl-L-glutamate peptidase I \linebreak (NAALADase I), NAAG peptidase or prostate-specific membrane antigen (PSMA) \dots
\end{document}
I have the following latex code:
% Preamble
% ---
\documentclass{article}
% Packages
% ---
\usepackage{amsmath}
\usepackage{graphicx}
\begin{document}
\title{Electronics Equations}
\author{Tyler Hilbert}
\date{}
\maketitle
\begin{figure}
\includegraphics[width=50mm]{FormulaWheel.png}
\end{figure}
Ohm's Law: V = I*R
\bigskip
Current: I = dQ/dt
Voltage: V = dw/dQ
Power: p = dw/dt
\end{document}
When I compile and create a pdf I get the following result:
What I am wondering is why is the figure after all the equations? I put the figure in before the equations because I wanted it at the beginning. How can I make it at the top of the document where it is relative to the other elements like in the ordering in the code?
You are using the figure environment, which is a float environment. The idea is to let latex figure out its optimal place. If you do not want that, than just use \includegraphics[width=50mm]{FormulaWheel.png} directly (just delete the \begin{figure} and \end{figure} lines).
You can find more details about floats here.
I am new to latex and I wrote the below tex code on Texmaker editor.
What I want to do is to add the "University" section without any numbering preceeding it and to be centered horizontally, because when I run the code I find that the word "University" is displayed but it is preceeded by a number and I do not want to display any number preceeding that word.
code:
\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{graphicx}
\usepackage{kpfonts}
\author{Anan}
\pagestyle{plain}
\begin{document}
\section{University}
\end{document}
\section*{\centering University}
% * removes numbering for _this_ \section instance,
% \centering within environment centres the title.
Note however, that this is a local solution, and that it's better practice (and easier for you to make later document-global changes) to re-define the \section, \subsection, ... environments using the titlesec package, as is described well in Alan Munn:s answer in the following tex.stackexchange thread:
https://tex.stackexchange.com/questions/8546/section-heading-centering-problem
All you have to do is to edit your line 9:
\section{University}
this way:
\section*{\centering University}
since the command \section* produces unnumbered sections.
Further, if you want to to include an unnumbered section to your table of contents, you can add
\addcontentsline{toc}{section}{University}
(this time without \centering) just after. The resulting code:
\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{graphicx}
\usepackage{kpfonts}
\author{Anan}
\pagestyle{plain}
\begin{document}
\tableofcontents
\section*{\centering University}
\addcontentsline{toc}{section}{University}
Text.
\end{document}
For some reason I thought it would be nice to have inline figures (i.e. no floats) just like the equation environment. They would have to be numbered, as I want to be able to refer to them later on. I've come up with two attempts, but both have their shortcomings. I'm hoping for some feedback that can sort me out.
The first attempt uses 3 minipages (see the code below). This looks nice as the figure number is aligned vertically with the middle of the figure. However, as the width of the figure approaches the width of the page, things start to break down. Also, it doesn't behave very nicely at pagebreaks.
The second attempt uses the equation environment with a different label. Apart from the fact that I don't know if this is a sensible thing to do, it produces extra whitespace in the beginning of the next paragraph. It also doesn't align the label vertically in the center, but puts it on the bottom.
Here's an example of both attempts:
\documentclass{article}
\usepackage{pgf,tikz}
\usepackage{lipsum}
%
% Attempt 1
%
% Uses 3 minipages.
% Breaks if figure is wide, and at the bottom of a page.
%
\usepackage{calc}
\newlength{\figlabelwidth} % width of label
\newlength{\imgwidth} % max. width of figure
\newenvironment{inlinefig1}
{
\refstepcounter{figure} % increase figure number
\begin{center} % don't know if this is necessary
\setlength{\figlabelwidth}{\widthof{(Fig. \thefigure)}}
\setlength{\imgwidth}{\textwidth - \figlabelwidth - \figlabelwidth}
\setlength{\imgwidth}{0.9\imgwidth} % to be on the safe side
\begin{minipage}{\figlabelwidth}\makebox[\figlabelwidth]{}\end{minipage} % ghost minipage for centering
\hfill
\begin{minipage}{\imgwidth}\begin{center} % minipage for figure
}
{
\end{center}\end{minipage}
\hfill
\begin{minipage}{\figlabelwidth}(Fig. \thefigure)\end{minipage} % minipage for label
\end{center}
}
%
% Attempt 2
%
% Uses an equation environment with relabeled labels.
% Label is not centered vertically, and produces extra whitespace in the paragraph after it.
%
\def\theoldequation{\theequation} % save the old equation format
\newenvironment{inlinefig2}
{
\refstepcounter{figure} % increase figure number
\def\theequation{Fig. \arabic{figure}} % switch to figure numbering
\begin{equation}
}
{
\end{equation}
\def\theequation{\theoldequation} % reset to old equation label format
\addtocounter{equation}{-1} % correct the equation numbering
}
\begin{document}
\noindent \lipsum[1]
\begin{inlinefig1}
\begin{tikzpicture}
\draw (0,0) grid +(12,2);
\end{tikzpicture}
\end{inlinefig1}
\lipsum[2]
\begin{inlinefig2}
\begin{tikzpicture}
\draw (0,0) grid +(12,2);
\end{tikzpicture}
\end{inlinefig2}
\lipsum[3]
\end{document}
Do you guys have any better ideas, or suggestions to fix the any of the shortcomings? Thanks!
If you use the "float" package, you can specify H as a placement, which makes it appear exactly "here".
\newbox\inlinefigbox
\newenvironment{inlinefig3}
{
\refstepcounter{figure} % increase figure number
\setbox\inlinefigbox=\hbox\bgroup
}
{
\egroup
\hbox to \hsize{\hfil \box \inlinefigbox \hss (Fig. \arabic{figure})}
}