I'm trying to write a macro that positions text in the margin of a LaTeX document. The text should appear in the same line the macro is called. Horizontal text position should be relative to the absolute border of the paper rather than the left side of the text.
I tried with the tabto package using the \tabto* command and then jump back to the location in the text with \tabto*{\TabPrevPos}. This works well but since tabto positions relative to the border of the text the result is different if you are in a list environment or similar.
So the whole command looks similar to:
\newcommand{\sidenote}[1]{%
\tabto*{\sidenoteskip}%
\smash{%
\begin{minipage}[t][1ex][t]{\sidenotewidth}%
\textbf{#1}%
\end{minipage}%
}%
\tabto*{\TabPrevPos}%
}
Does anywone have an idea how I can position the minipage relative to left paper border and jump back to the location where the macro was called?
Related
I was hoping anyone could help me with this. I am working with Latex and the Tikz package (I'm a new user on both) on a document cover using 2 figures so it looks like this:
That is, the background image leaves a thin margin on all sides, and the logo falls off-margin to the right and bottom. So, I enter the code overlaying the the logo over the background using Tikz, and as soon as I edit the coordinates to get the logo to go off-margin either on the right or bottom, the background image starts moving to the left and top until it sticks to the opposing borders of the page, like this:
My question is, is there a way to have the superimposing image to fall off the margins while keeping the background image properly centered?
Here is the code I'm using:
\usepackage{mwe,tikz}
\begin{figure}
\begin{tikzpicture}[
every node/.style={anchor=south west,inner sep=20pt},
x=1mm, y=1mm,
]
\node (fig1) at (0,0)
{\includegraphics[scale=0.2]{Images/Background.jpg}};
\node (fig2) at (124,-23)
{\includegraphics[scale=1.5]{Images/Logo.png}};
\end{tikzpicture}
\end{figure}
I first tried using the Overpic package instead, but I found it to be rather limited (or I couldn't figure it out well enough probably). I then tried using \centering and other horizontal and vertical centering techniques in combination with Tikz, but to no avail.
A figure environment is a floating objects, which allows latex to find a good location within the text flow. If you want an image at a very specific position, like a title page, you shouldn't use a figure environment
using the overlay option will make sure that the actual size of the tikzpicture does not influence the positioning and thus a cutoff logo won't influence the rest of the page
I also suggest the remember picture option which allows you to position your nodes with respect to the page. This way you can place the big picture in the centre of the page and the smaller picture at the lower right corner (shift it around with the xshift and yshift keys)
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[remember picture,overlay]
\node at (current page.center) {\includegraphics[width=.9\paperwidth,height=.9\paperheight]{example-image-10x16}};
\node at ([xshift=-2cm,yshift=1cm]current page.south east) {\includegraphics[width=15cm]{example-image-duck}};
\end{tikzpicture}
\end{document}
I am trying to create a vertically centered line inside normal text. I also want to control length and width of the line as the dash or "---" are to thin and/or short.
I want something like the math-command \rule{length}{width}, which is centered like a dash and not floored.
Example (not created with Latex)
Simply put, \rule can be raised just by specifying how high you want it.
\rule[0.5ex]{1in}{0.4pt}
raises a \rule{1in}{0.4pt} 0.5ex above the baseline.
In my thesis I'm including already published papers. I've extracted pages as individual EPS files and I'm shrinking them so they fit on one page within the margins (\pageScale).
\hfill{}\includegraphics[scale=\pageScale]{Integrative-Theory-Associative/eps-pages/page-1}\hfill{}
While this works ok, the pages appear extremely small to fit in the margins. I'd like to increase the size of the graphics beyond the margins such that header and page number information would overlap with margins of the inserted pages.
eso-pic allows me to fill the whole page with my inserted pages, but the header and page number overlap with the text in the inserted pages:
\mbox{}
\AddToShipoutPictureBG*{
\includegraphics{Integrative-Theory-Associative/pdf-pages/page-1.pdf}
}
\newpage
I's like to scale down and centre the graphics on the page so they are as big as possible while text within the graphics is not behind the header and is within the margins.
I don't mind manually figuring out the right scale for graphics, but I can't figure how to place the centre of a smaller graphic in the centre of the margins. \AtPageCenter
does not do what I expected, centre the centre of the graphic, not centre the lower left of the graphic.
In the example below I've used some of adjustbox's prowess to adjust included content:
\documentclass{article}
\usepackage{fancyhdr,lipsum}% Just for this example
\fancyhf{}
\fancyhead[C]{This is some random header text}
\fancyfoot[C]{\thepage}
\renewcommand{\headrulewidth}{.4pt}
\renewcommand{\footrulewidth}{.4pt}
\pagestyle{fancy}
\usepackage[export]{adjustbox}
\usepackage{eso-pic}
\newcommand{\pictureincenteroftextblock}[2][]{%
\AddToShipoutPictureBG*{%
\AtTextLowerLeft{%
\raisebox{.5\textheight}{%
\hspace*{.5\textwidth}%
\makebox[0pt]{\includegraphics[max width=\textwidth,max height=\textheight,valign=c,#1]{#2}}%
}%
}%
}%
}
\begin{document}
\lipsum[1-5]
\clearpage
\mbox{}% Just put something on this page.
\pictureincenteroftextblock{example-image-a}
\clearpage
\mbox{}% Just put something on this page.
\pictureincenteroftextblock{example-image-10x16}
\clearpage
\mbox{}% Just put something on this page.
\pictureincenteroftextblock{example-image-1x1}
\clearpage
\mbox{}% Just put something on this page.
\pictureincenteroftextblock{example-image-a4}
\end{document}
With the [export] option, adjustbox adds its key-values to graphicx's \includegraphics options. Those I've used are max width and max height which will shrink the included image (or page from a PDF) if the width or height exceeds these maxima while still maintaining the included image/page aspect ratio. Additionally, valign=c will align the content in a vertically centred fashion.
eso-pic is used to place the image in the background, starting at the lower-left part of the text block. Then, through standard spacing commands, it's raised into position (\raisebox) and shoved over (\hspace) to the centre of the text block. Finally the image is horizontally centred (\makebox[0pt]).
Hi I'm using LateX. I have a block of text that I'd like to have a small box like space highlighting the are (just like a \begin{equation} but for text).
Is there such a thing in LateX?
I'm not 100% sure what you're asking I'm afraid, but if you just want to indent text with a margin on each side of the page to make it stand out, you can use...
\begin{quotation}
Quotation is good for long blocks of text that you want highlighted
\end{quotation}
\begin{quote}
Quote is suited to a single block of quoted text.
\end{quote}
If you actually want to have a physical black box around the text, you might want to consider wrapping it in a tabular / table, or you might want to delve into minipages and/or par box environments...
Is \makebox what you're looking for?
To create boxes of text that behave differently from the rest of the text, we can use
\makebox[width][pos]{text}
The width sets the width the of the box. The pos sets the positioning of the text - either r (right justified text), l (left justified), or s (stretched to fill the box). If the pos parameter is left out, as in \makebox[1in]{centerme}, the text is centered. The text is placed in the box. If you want to draw a box around the text, use \framebox just as you would use \makebox.
\mbox{text} and \fbox{text} are quick versions of \makebox and \framebox, which create a box to fit the size of the text.
There are some more examples at http://www.artofproblemsolving.com/wiki/index.php?title=LaTeX:Layout#Boxes
I have a tikz picture with a circle node which has a number inside.
I want this number to change with the slides but to be of fixed size. (-> not mess up the circle).
This one isn't working, the circle gets as big as if it has to hold all 3 numbers.
\tikz[baseline]
\node [fill=blue!20,draw,circle,anchor=base] (node1)
{
\only<1-3>{3} \only<4-6>{8} \only<7->{11.5}
};
Here the values are 3 on slides 1-3, 8 on slides 4-6 and else 7.
I observed the following:
The spaces between \only{} are always rendered (\only, when not active, is a "zero-width character"; TeX does not discard spaces between characters)
Set the width of the text explicitly using "text width=...". This implicitly puts the content into a minipage.
Note that the "baseline" property does not work anymore as expected.
"text centered" ensures the alignment for the case that the content is not exactly "text-width"
The "overprint" environment only automatically determines the height of the content, not the width.
To conclude, this works for me (I tried it):
\tikz[baseline]
\node [fill=blue!20,draw,circle,anchor=base,text width=4ex,text centered,inner sep=0] (node1)
{
\only<1-3>{3}\only<4-6>{8}\only<7->{11.5}
};
EDIT: This works with the correct baseline:
\tikz[baseline=(node1.base)]
\node [fill=blue!20,draw,circle] (node1)
{
\begin{minipage}{4ex}
\centering
\only<1-3>{3}\only<4-6>{8}\only<7->{11.5}
\end{minipage}
};
There are a couple of ways to do this:
You could use a 'overlay' environment which calculates the maximum size needed.
You could use \makebox[width]{ }.
Or simply use the 'minimum width' and 'minimum height' options on the node.
...