Question:
I use caution statements in my LaTex documents using the code below which works, but I need the caution symbol to be centre aligned against the text like below image that shows current and expected. How?
\newlist{Caution}{enumerate}{1}
\setlist[Caution]{label=\scshape{\color{black}\colorbox{yellow}{{\textbf{{\faWarning} caution}}}},leftmargin=*}
\begin{Caution}
\item {A hazardous situation which, if not avoided, could result in minor or moderate njury.}
\end{Caution}
Edit 1: Minimum Reproducible Example
\documentclass[11pt,a4paper]{article}
\usepackage[a4paper,bindingoffset=0mm,left=20mm,right=20mm,%
top=30mm,bottom=20mm,footskip=10mm,headsep=10mm]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{palatino}
\usepackage{enumitem}
\usepackage{xcolor, fontawesome}
\usepackage{multicol}
\twocolumn
\newlist{Caution}{enumerate}{1}
\setlist[Caution]{label=\scshape{\color{black}\colorbox{yellow}{{\textbf{{\faWarning} caution}}}},leftmargin=*}
\begin{document}
\begin{Caution}
\item {A hazardous situation which, if not avoided, could result in minor or moderate injury.}
\end{Caution}
\end{document}
You can control the vertical position of any box with the command \raisebox and this can be used to raise or lower the label. But it is not a very good idea for your problem as the amount that the label must be lowered depends on the number of lines in the item text. More, it is not very easy to pass optional positioning parameters to a label, and this solution really lacks flexibility, but I included it for comparisons and completeness.
I propose another solution with minipages. It is sufficient to put the caution label and the text in minipages and to specify a center ([c]) vertical alignment.
The width of either parts are computed with the calc package and it adapts to font size modifications. There is an optional argument that allows to control the spacing between the label and the text. Default value of this parameter mimics the spacing in a list, but it can be adjusted if required.
\documentclass[11pt,a4paper]{article}
\usepackage[a4paper,bindingoffset=0mm,left=20mm,right=20mm,%
top=30mm,bottom=20mm,footskip=10mm,headsep=10mm]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{palatino}
\usepackage{enumitem}
\usepackage{xcolor, fontawesome}
\usepackage{multicol}
\usepackage{calc}
\twocolumn
\newcommand{\cautionmark}{\scshape{\color{black}\colorbox{yellow}{\faWarning caution}}}
\newlist{Caution}{enumerate}{1}
\setlist[Caution]{label=\raisebox{-0.5cm}[0pt][0pt]{\cautionmark},leftmargin=*}
\newcommand{\newcaution}[2][0.7em]{
\begin{minipage}[c]{\widthof{\cautionmark}}
\cautionmark
\end{minipage}%
\hfill%
\begin{minipage}[c]{\linewidth-\widthof{\cautionmark}-#1}
#2
\end{minipage}
}
\begin{document}
\begin{Caution}
\item A hazardous situation which, if not avoided, could result in
minor or moderate injury.
\end{Caution}
\newcaution{A hazardous situation which, if not avoided, could result
in minor or moderate injury.}
\newcaution[1cm]{A hazardous situation which, if not avoided, could result
in minor or moderate injury.}
\end{document}
Related
I am having issues with a report I am writing. First time using latex and after getting some help on here regarding some tables weirdness I again have a silly frustrating issue. Figures don't stay where I put them. I made a MWE Posted Below
\documentclass{article}
\usepackage{graphicx}
\graphicspath{ {./Figures/} }
%%%%%% Referencing %%%%%%
\usepackage{natbib}
\bibliographystyle{abbrvnat}
\setcitestyle{authoryear,open={(},close={)}}
\title{MWE}
\begin{document}
\maketitle
\section{Introduction}
The average sea surface temperature (SST) trend is shown in Figure \ref{fig:SST}.
\section{Figures}
\begin{figure}
\includegraphics[width = \linewidth]{Figures/SST.png}
\label{fig:SST}
\end{figure}
\section{References}
\bibliography{References.bib}
\bibliographystyle{agsm}
\end{document}
I expect, probably an error, for the figure to be inserted under the Figures subheading however it appears on the next page after references. I have to refer to my figure in the text, hence the \ref{fig:SST} so it is clickable. It's not a size issue as there is more than enough space on the page to accommodate the figure. Even if that was the issue I would expect the references subheading to be after it.
Most latex classes use so called floats for figures, tables etc. The idea is that latex will automatically find a good place for your images and avoid ugly white space.
To make use of the abilities of latex to produce a good looking output, you must specify possible placements with floating specifier such as [htbp], which allows latex to place the image here, at the top, at the bottom or an a separate page.
Also if you want to use the \label-\ref mechanism, your figure must have a caption (and the label inside or after the caption).
\documentclass{article}
\usepackage{graphicx}
\graphicspath{ {./Figures/} }
%%%%%% Referencing %%%%%%
\usepackage{natbib}
\bibliographystyle{abbrvnat}
\setcitestyle{authoryear,open={(},close={)}}
\title{MWE}
\begin{document}
\maketitle
\section{Introduction}
The average sea surface temperature (SST) trend is shown in Figure \ref{fig:SST}.
\section{Figures}
\begin{figure}[htbp]
\includegraphics[width = \linewidth]{example-image-duck}
\caption{test}
\label{fig:SST}
\end{figure}
\section{References}
\bibliography{References.bib}
\bibliographystyle{agsm}
\end{document}
Generally, LaTeX's attitude is ‘you write the text, let me worry about placing the figures’.
Floats (that is, figures and tables) will float to where LaTeX thinks they go best. I can't remember the precise rules in the article style, but generally they float to the top of the nearest following page that has room for them. LaTeX won't fill too much of a page with figures, so if you have a dense sequence of large-ish figures, some of them can end up quite a long way away from the point in the source text where they're written.
This is normal, and how figures and tables appear in the majority of published books and articles.
You'll usually write a caption:
\begin{figure}
\includegraphics{...blah...}
\caption{This is a caption for my figure\label{fig:SST}}
\end{figure}
Then you can write
...this is shown in Figure~\ref{fig:SST}
If you want to, you might add ...on p.\thinspace\pageref{fig:SST} and LaTeX will insert the page number where the figure ends up. Also, see the prettyref package.
As mentioned in the other answer, you can add placement specifiers like [ht], which give LaTeX permission to put the figure ‘here’ or at the top of a page, but that doesn't force anything. It is possible to fight with LaTeX about this (the Overleaf docs give some hints), but it's generally not worth it in my experience.
That said, one bit of guidance it's useful to give LaTeX is something like \renewcommand{\floatpagefraction}{.8}, which says that LaTeX is allowed to use as much as 80% of the page for floats (ie, figures and tables) – the default value is a bit tight (there are more comments on this in this TeX.SE question – tex.stackexchange.com is generally a better site for LaTeX-related questions).
If you do feel compelled to fight/fiddle with float placement, do it at the very end of the process, where you're fine-tuning the punctuation of your document. Small changes in the document can have big effects on where floats end up, and it's simply not worth worrying about this until your document is almost finalised.
Your final puzzlement was about the figure ending up after the references. In the case of your document, the figure goes on p.2, so there's plenty of space on p.1 for LaTeX to carry on setting text, so naturally it puts the references there. Since you generally do want the references to go at the very end of an article, this is a case where it's reasonable to exert a little control over placement, and a good idea would be to put \clearpage before the References section. What that does is to make a new page and force out any floats which are still in the queue waiting for space to appear.
The proof copies of a book laid out with KOMA scrbook show that the inner margins are too narrow. I had BCOR set to 10mm and want to increase them, but my experiments with BCOR set to 20mm show that the layout is the same independent what BCOR value I set. Here my MWE:
\documentclass{scrbook}
\KOMAoptions{paper=
128.5mm:198.4mm, %(5,06" x 7,91") %ziel
BCOR=20mm,
twoside,
headinclude=false, footinclude=false,
headings=normal,
titlepage=true,
% draft=true,
DIV=9, %ziel kleines buch
fontsize=12pt,
}
\usepackage[german]{babel}
\usepackage{lipsum}
\usepackage{geometry}
\usepackage[a4,axes,cross,pdftex,center]{crop}
\begin{document}
\frontmatter
\tableofcontents
\mainmatter
\part{ Philosophie}
some text
\lipsum
\lipsum
\end{document}
What is wrong?
My real question is: how can I just move the text area on both pages to the outside (i.e. making the gutter wider) without changing the text area size (and thus preserve line breaks)?
I found a hint in some other questions answered before and the problem was caused by the interaction between the KOMA script and the geometry package. Using the geometry package recalculates the page layout and overwrites the one calculated by scrbook including the BCOR value. This can be avoided when adding the option pass to geometry as in
`\usepackage[pass]{geometry}`.
In general the interaction between the layout calculated by KOMAscript and other package can lead to surprises. The discussion in https://tex.stackexchange.com/questions/182821/div-and-bcor-setting-in-koma-best-practices/183839 is very useful.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 3 years ago.
Improve this question
I am trying to write a CV in Latex, but now I am stuck. Since I want to learn Latex, I don't really want to just use a template.
I am thinking about one page divided in to columns/minipages:
Left column: an image + contact information etc.
Right Column: Education, experience, volunteer work etc.
Tried minipages and columns, but the image is destroying the whole format... Tried to use parts from templates, which worked fine, i.e. secsty etc. See example under.
Not a specific question, but hope someone has a good idea for how to make something out of this idea :)
Example:
%Preamble
\documentclass[a4paper]{article}
\usepackage{graphicx}
\usepackage{geometry}
\geometry{a4paper, total={170mm,257mm}, left=10mm, top=10mm}
\pagestyle{empty}
%%% Custom sectioning (sectsty package)
\usepackage{sectsty}
\sectionfont{\usefont{OT1}{phv}{m}{n}\sectionrule{0pt}{0pt}{-10pt}{1pt}}
\subsectionfont{\usefont{OT1}{phv}{m}{n}}
%Document
\begin{document}
\begin{minipage}[250mm]{0.4\linewidth}
\includegraphics{image.png}
Date of birth:
Phone:
Email:
\end{minipage}
\begin{minipage}[250mm]{0.65\linewidth}
\part*{Name}
\section*{EDUCATION}
\section*{EXPERIENCE}
\end{minipage}
\end{document}
It is great to see that you don't simply copy one of the existing templates, but want to learn some latex instead.
Some comments about your code:
if you want the minipages besides each other to emulate columns, their combined sum has to be equal or smaller than the linewidth. In your example 0.4+0.65= 1.05, so they won't fit in one line. In fact I would make them a bit smaller and add a \hfill between to get a bit of space between them
to make sure each minipage is only as wide as you specified, I would add the [width=\linewidth] option to the image. This will automatically scale the image correctly
if you want both minipages in one line, don't leave an empty line between them. In latex and empty line in the source code is interpreted as a paragraph break, thus forcing your second minipage in a new line
To get a better vertical alignment of the image, I would remove the optional height argument from the minipage and let tex determine how high your minipages are and add the options [T] and [b] respectively to determine the vertical alignment
this is more a design question: at the moment your page geometry is highly asymmetric. You can visualise this by adding showframe to your geometry options, e.g. \geometry{a4paper, total={170mm,257mm}, left=10mm, top=10mm,showframe}. Are you sure this is a good choice for a CV?
%Preamble
\documentclass[a4paper]{article}
\usepackage{graphicx}
\usepackage{geometry}
\geometry{a4paper, total={170mm,257mm}, left=10mm, top=10mm}
\pagestyle{empty}
%%% Custom sectioning (sectsty package)
\usepackage{sectsty}
\sectionfont{\usefont{OT1}{phv}{m}{n}\sectionrule{0pt}{0pt}{-10pt}{1pt}}
\subsectionfont{\usefont{OT1}{phv}{m}{n}}
%Document
\begin{document}
\noindent
\begin{minipage}[T]{0.4\linewidth}
\includegraphics[width=\linewidth]{example-image-duck}
Date of birth:
Phone:
Email:
\end{minipage}%
\hfill
\begin{minipage}[b]{0.55\linewidth}
\part*{Name}
\section*{EDUCATION}
\section*{EXPERIENCE}
\end{minipage}
\end{document}
I have a LaTeX-document using the class
\documentclass[12pt,a4paper]{scrbook}
and I changed some parameters for positioning the floats:
\renewcommand{\topfraction}{1} %default: 0.7
\renewcommand{\bottomfraction}{1} %default: 0.3
\renewcommand{\textfraction}{0.1} %default: 0.2
\renewcommand{\floatpagefraction}{1} %default: 0.6
\setcounter{topnumber}{3}
\setcounter{bottomnumber}{3}
I have two graphics that should be among each other and fill one single page. I don't know why, but because LaTeX always splits both graphics on two pages, I put both graphics into one figure-environment. It doesn't matter whether I use [ht] or [p] the figure with both graphics moves to the end of the chapter. I don't get any overfull warnings. So I think it might not the reason that the figure is too large.
\begin{figure}[p]
\centering
\includegraphics{graphic1.pdf}
\newcaption{caption 1} % <-- using \usepackage{picins}
\label{fig:pic1}
\vspace{5mm}
\includegraphics{graphic2.pdf}
\newcaption{caption 2}
\label{fig:pic2}
\end{figure}
Is there someone, who can explain that behaviour of LaTeX and can recommend a solution.
This is standard behaviour in latex because it takes care of all positioning. I personally wouldn't mess this up and would instead refer to the images.
If you nevertheless want to position them at the given line in the text:
Use the package float and place your images this way.
\usepackage{float}
\begin{figure}[H]
...
\end{figure}
I misunderstood the meaning of \floatpagefraction....
It describes the minimum size that a float must have, so that you can use [p]. Setting it to a value of 1 (100% of the page) makes definitely no sense.
bad:
\renewcommand{\floatpagefraction}{1}
good:
\renewcommand{\floatpagefraction}{0.6} %default: 0.6
Default values generally are not so bad......
If you want to have your images right where you want them to be, just use
/usepackage{float}
and edit your image code as follows.
\begin{figure}[H]
\centering
\includegraphics{graphic1.pdf}
\newcaption{caption 1} % <-- using \usepackage{picins}
\label{fig:pic1}
\end{figure}
\vspace{5mm}
\begin{figure}
\includegraphics{graphic2.pdf}
\newcaption{caption 2}
\label{fig:pic2}
\end{figure}
I am writing a personal statement in latex. I don't want the big margin at the top of the page not big title taking a lot of space. I just like to make the layout compact but still clearly spaced with title, name and other necessary information, since there may be restriction on the number of pages. One example would be http://www.hsc.unt.edu/education/CIM/Documents/PS-Sample2_000.pdf. I wonder where to find some good latex templates or examples?
Thanks and regards!
I would use the geometry package to establish the desired margins. To get the margins in your sample document, try:
\usepackage[left=1in,right=1in,top=1in,bottom=1in]{geometry}
Your next requirement was to fix the title block. LaTeX uses the internal command \#maketitle to format the title block. You can redefine this as you like. To achieve the same title block style as in the sample document, use:
\usepackage[svgnames]{xcolor}% provides colors for text
\makeatletter% since there's an at-sign (#) in the command name
\renewcommand{\#maketitle}{%
\begin{center}
\parskip\baselineskip% skip a line between paragraphs in the title block
\parindent=0pt% don't indent paragraphs in the title block
\textcolor{red}{\bf\#title}\par
\textbf{\#author}\par
%\#date% remove the percent sign at the beginning of this line if you want the date printed
\end{center}
}
\makeatother% resets the meaning of the at-sign (#)
The \#title, \#author, and \#date commands will print the title, author, and date. You can use whatever formatting commands you like to set the text in bold, different colors, etc.
Put all of the above commands in the preamble of the document. The preamble is the space between \documentclass and \begin{document}.
\documentclass{article}
% this is the preamble
% put all of the above code in here
\title{Personal Statement}
\author{Tim}
\begin{document}
\maketitle% prints the title block
Emergency medicine has always been a passion of mine\ldots
\end{document}
Attempt #1: I've used the following style file, which I call cramp2e, for similar purposes. It is probably not right for you, but have a look:
\oddsidemargin -1cm
\evensidemargin -2cm
\topmargin 1cm
\textheight 24cm
\textwidth 19cm
\headheight 0cm
\headsep .7cm
\footskip .7cm
\parskip .2cm
\paperheight 25cm
\setlength\voffset{-.33in}
\setlength\hoffset{-.25in}
Any good?
Postscript This is for A4 size paper.
A slightly less LaTeX-ey solution would be to not use the \maketitle command. A couple of times I've simply used this as my title(marginsize helps too).
Set up smaller margins:
\documentclass{article}
\usepackage{anysize}
\marginsize{1cm}{1cm}{1cm}{1cm}
(EDIT: 1cm might be even better..)
Minimal title:
\begin{document}
\begin{center}
\section*{My Document Title}
\today
\end{center}
% content goes here
\end{document}
The result looks something like: