Omit unwanted text stretching in latex documents - latex

I have the following problem with my latex document (see the red marked area in the picture). I want to scratch the words like in the green marked area.
I guess that this misbehavior evolves through my style settings.
\documentclass[fontsize=12pt,parskip=full,normalheadings,a4paper]{scrartcl}
\usepackage[a4paper,inner=40mm,outer=30mm,top=33mm,bottom=30mm]{geometry}
\usepackage[utf8x]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{times} % font-style
\usepackage{graphicx} % figures
\usepackage[square]{natbib} % for references
\usepackage{csquotes} % quotes
\usepackage{verbatim} % comment-environment
\linespread{1.10} % line distance
\DeclareGraphicsRule{.pdftex}{pdf}{.pdftex}{} % for xfig
\usepackage{tabularx} % tables
\usepackage{srcltx} % forward/reverse search in dvi
\usepackage[perpage,marginal,hang]{footmisc} % make special footnote symbols
\sloppy % prevent overfull boxes
%\usepackage[ngerman]{babel} % damit das Inhaltsverzeichnis auf deutsch ist
%% styling the header and footer
\usepackage[headsepline]{scrpage2} % separation line in the header
\clearscrheadfoot
\automark[subsection]{section}
\lehead[]{\leftmark}
\lohead[]{\rightmark}
\rehead{\pagemark}
\rohead{\pagemark}
\pagestyle{scrheadings}
%% color
\usepackage{color}
\usepackage{xcolor}
\definecolor{darkred}{rgb}{.5,0,0}
\definecolor{darkblue}{rgb}{0,0,.5}
\usepackage[plainpages=false,pdfpagelabels,colorlinks=true,urlcolor=darkblue,pagecolor=darkred,
citecolor=black,linkcolor=black]{hyperref}
%% settings for caption
\usepackage[font=footnotesize,labelfont=bf,textfont=it,singlelinecheck=false,format=hang]{caption}
% counter hack for setting the counter for the listings
\usepackage{chngcntr}
\counterwithin{figure}{section}
\counterwithin{table}{section}
If you can, please tell me, which option I have to change in order to get a 'fine word stretching' for the whole document.
As always, thanks for your fast and helpful answers.
Matthias

I think that your problem is connected with url. Url adress is printed as one word without spaces. You may add \newline before "http://...."

Related

LaTex: Get figure caption to align with image

Thanks in advance for your help!
I know similar questions have been asked, but I cant get any of them to work. I am trying to get the caption to be the same width as the image I am captioning.
Here is the code: it results in all of the words falling in line after the Figure title (image attached to show what it currently looks like.1
\documentclass[twoside,twocolumn]{article}
\usepackage{blindtext} % Package to generate dummy text throughout this template
\usepackage[sc]{mathpazo} % Use the Palatino font
\usepackage[T1]{fontenc} % Use 8-bit encoding that has 256 glyphs
\linespread{1.05} % Line spacing - Palatino needs more space between lines
\usepackage{microtype} % Slightly tweak font spacing for aesthetics
\usepackage[english]{babel} % Language hyphenation and typographical rules
\usepackage[hmarginratio=1:1,top=32mm,columnsep=20pt]{geometry} % Document margins
\usepackage[hang, small,labelfont=bf,up,textfont=it,up]{caption} % Custom captions under/above floats in tables or figures
\usepackage{booktabs} % Horizontal rules in tables
\usepackage{lettrine} % The lettrine is the first enlarged letter at the beginning of the text
\usepackage{enumitem} % Customized lists
\setlist[itemize]{noitemsep} % Make itemize lists more compact
\usepackage{abstract} % Allows abstract customization
\renewcommand{\abstractnamefont}{\normalfont\bfseries} % Set the "Abstract" text to bold
\renewcommand{\abstracttextfont}{\normalfont\small\itshape} % Set the abstract itself to small italic text
\usepackage{titlesec} % Allows customization of titles
\renewcommand\thesection{\Roman{section}} % Roman numerals for the sections
\renewcommand\thesubsection{\roman{subsection}} % roman numerals for subsections
\titleformat{\section}[block]{\large\scshape\centering}{\thesection.}{1em}{} % Change the look of the section titles
\titleformat{\subsection}[block]{\large}{\thesubsection.}{1em}{} % Change the look of the section titles
\usepackage{fancyhdr} % Headers and footers
\pagestyle{fancy} % All pages have headers and footers
\fancyhead{} % Blank out the default header
\fancyfoot{} % Blank out the default footer
\fancyhead[C]{Test} % Custom header text
\fancyfoot[RO,LE]{\thepage} % Custom footer text
\usepackage{titling} % Customizing the title section
\usepackage{hyperref} % For hyperlinks in the PDF
\usepackage{graphicx}
\graphicspath{ {./images/} }
\setlength{\droptitle}{-4\baselineskip} % Move the title up
\pretitle{\begin{center}\Huge\bfseries} % Article title formatting
\posttitle{\end{center}}
\setlength\parindent{24pt}
\usepackage{float}
\usepackage{floatrow}
\usepackage{pdfpages}
\newsavebox\mysavebox
\begin{document}
\begin{figure}[t]
\includegraphics[width=7.5cm]{img1.jpg}
\centering
\caption{Imaged tunnel slide of yeast. This image depicts how yeast cells were counted to determine sample concentrations. Small budding cells were not included in the total cell count. Note: 4× relay lens and 40× objective used. A ${1.75x10^6}$ mL volume is shown.}
\label{fig:mesh1}
\end{figure}
\end{document}
Very important: never ignore error messages. If an error tells you that you mustn't use floatrow with the float package, don't ignore this error and remove one of the packages.
Then if you don't want the caption to have an hanging indent, remove the hang option from the caption package.
don't abuse the letter x as multiplication symbol. Use \times instead.
have a look at the siunitx package to get correct spacing and fonts for units
with 7.5cm your image is too wide for your column, a warning in the log file will tell you this. You can avoid this by using \linewidth.
\documentclass[twoside,twocolumn]{article}
\usepackage{blindtext} % Package to generate dummy text throughout this template
\usepackage[sc]{mathpazo} % Use the Palatino font
\usepackage[T1]{fontenc} % Use 8-bit encoding that has 256 glyphs
\linespread{1.05} % Line spacing - Palatino needs more space between lines
\usepackage{microtype} % Slightly tweak font spacing for aesthetics
\usepackage[english]{babel} % Language hyphenation and typographical rules
\usepackage[hmarginratio=1:1,top=32mm,columnsep=20pt]{geometry} % Document margins
\usepackage[small,labelfont=bf,up,textfont=it,up]{caption} % Custom captions under/above floats in tables or figures
\usepackage{booktabs} % Horizontal rules in tables
\usepackage{lettrine} % The lettrine is the first enlarged letter at the beginning of the text
\usepackage{enumitem} % Customized lists
\setlist[itemize]{noitemsep} % Make itemize lists more compact
\usepackage{abstract} % Allows abstract customization
\renewcommand{\abstractnamefont}{\normalfont\bfseries} % Set the "Abstract" text to bold
\renewcommand{\abstracttextfont}{\normalfont\small\itshape} % Set the abstract itself to small italic text
\usepackage{titlesec} % Allows customization of titles
\renewcommand\thesection{\Roman{section}} % Roman numerals for the sections
\renewcommand\thesubsection{\roman{subsection}} % roman numerals for subsections
\titleformat{\section}[block]{\large\scshape\centering}{\thesection.}{1em}{} % Change the look of the section titles
\titleformat{\subsection}[block]{\large}{\thesubsection.}{1em}{} % Change the look of the section titles
\usepackage{fancyhdr} % Headers and footers
\pagestyle{fancy} % All pages have headers and footers
\fancyhead{} % Blank out the default header
\fancyfoot{} % Blank out the default footer
\fancyhead[C]{Test} % Custom header text
\fancyfoot[RO,LE]{\thepage} % Custom footer text
\usepackage{titling} % Customizing the title section
\usepackage{hyperref} % For hyperlinks in the PDF
\usepackage{graphicx}
\graphicspath{ {./images/} }
\setlength{\droptitle}{-4\baselineskip} % Move the title up
\pretitle{\begin{center}\Huge\bfseries} % Article title formatting
\posttitle{\end{center}}
\setlength\parindent{24pt}
%\usepackage{float}
\usepackage{floatrow}
\usepackage{pdfpages}
\newsavebox\mysavebox
\begin{document}
\begin{figure}[t]
\includegraphics[width=\linewidth]{example-image-duck}
\centering
\caption{Imaged tunnel slide of yeast. This image depicts how yeast cells were counted to determine sample concentrations. Small budding cells were not included in the total cell count. Note: 4× relay lens and 40× objective used. A ${1.75 \times 10^6}$ mL volume is shown.}
\label{fig:mesh1}
\end{figure}
\end{document}

LaTeX two-column layout does not keep text between borders

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}

How to disable numbering in latex?

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}

How to get heading only for the main matter in the report class?

I am writing my thesis in Latex, document class: report. I have got front matter containing of abstract, acknowledgement and so on.
I want to add header only to my main matter which starts with my first chapter:Introduction. I want the header to be the chapter number without the word "chapter" and the chapter title next to it. I also want the page number to appear in the centre on the bottom of the page in all pages of the main matter.
I don't want any header or line in any page of my front matter.
Can you please guide me? Thanks
Here it is the sample code that I am applying.
\documentclass[a4paper,12pt,titlepage]{report}
\usepackage{amsfonts}
\usepackage[english]{babel}
\usepackage{graphicx}
\usepackage{color}
\usepackage{colordvi}
\usepackage{amssymb}
\usepackage{natbib}
\usepackage[nottoc,notlot,notlof]{tocbibind}
\usepackage{setspace}
\usepackage{amsmath}
\usepackage{theorem}
\usepackage{lineno}
\usepackage{multirow}
\usepackage [toc,page]{appendix}
\usepackage{framed}
\usepackage{setspace}
\doublespacing
\usepackage[left=1.5in,top=2in,right=1in,bottom=2in]{geometry}
\begin{document}
\title{xxx}
\author{xxx}
\date{xxx}
\maketitle
\thispagestyle{empty}
\renewcommand{\thepage}{\roman{page}}
% here it comes my front matter for example:
\clearpage
\addcontentsline{toc}{chapter}{Abstract}
\chapter*{Abstract}
ABSTRACT CONTENTS
%then:
\clearpage
\cleardoublepage
\pagenumbering{arabic}
% here it starts my main matter:
\chapter{Introduction} %first chapter
\chapter{First Esssay in XXX} %second chapter
\end{document}
You have a number of options to set headers in a document. The most frequently-used package is fancyhdr.
First of all, you need to remove the word Chapter from the regular chapter mark. For this, add
\usepackage{etoolbox}
\makeatletter
%\newcommand{\updatechaptermark}{%
\appto\ps#fancy{%
\patchcmd{\chaptermark}% <cmd>
{\#chapapp\ }{}% <search><replace>
{}{}% <success><failure>
}%}
\makeatother
to your preamble. The above strips out \#chapapp\ (note the space) from \chaptermark as part of the call to \pagestyle{fancy}. That's required as fancyhdr may update \chaptermark upon calling \pagestyle{fancy}.
Second, you need to set the headers/footers. Here's a setting that yields what you're after:
\usepackage{fancyhdr}
\fancyhf{}% Clear header/footer
\fancyhead[C]{\leftmark}% Chapter mark
\fancyfoot[C]{\thepage}% Footer contains the page number
\renewcommand{\headrulewidth}{.4pt}% Header rule width
The above sets the header as \leftmark, which contains the \chaptermark setting (since \chaptermark actually issues \markboth{<leftmark>}{<rightmark>} with an empty <rightmark>).
\documentclass{report}
\usepackage{fancyhdr,lipsum}
\usepackage{etoolbox}
\makeatletter
%\newcommand{\updatechaptermark}{%
\appto\ps#fancy{%
\patchcmd{\chaptermark}% <cmd>
{\#chapapp\ }{}% <search><replace>
{}{}% <success><failure>
}%}
\makeatother
\fancyhf{}% Clear header/footer
\fancyhead[C]{\leftmark}
\fancyfoot[C]{\thepage}
\renewcommand{\headrulewidth}{.4pt}
\begin{document}
%\frontmatter
\pagenumbering{roman}
\title{xxx}
\author{xxx}
\date{xxx}
\maketitle
\thispagestyle{empty}
% here it comes my front matter for example:
\cleardoublepage
\tableofcontents
\cleardoublepage
\addcontentsline{toc}{chapter}{Abstract}%
\chapter*{Abstract} \lipsum[1]
\cleardoublepage
\pagenumbering{arabic}
\pagestyle{fancy}
\chapter{Introduction} \lipsum[1-50] % first chapter
\chapter{Methodology} \lipsum[1-50] % second chapter
\chapter{Conclusion} \lipsum[1-50] % last chapter
\end{document}
Note that \chapters are set by default using the plain style. If you wish this to be different, you'll have to redefine the plain page style.
You can achieve the same output using a different header/footer package like titleps.

text over figure in latex

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}

Resources