Text FormattingRotate and put text

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
buzon
Posts: 7
Joined: Tue Jan 17, 2012 1:08 am

Rotate and put text

Post by buzon »

Hello,

I would like to rotate the title over 45 degrees, and put it in some position on the cover page. The fragment of code I use is:

Code: Select all

\begin{turn}{-45}
\put(200pt,100pt){My report}
\end{turn}
The following error occurs:

Code: Select all

! A <box> was supposed to be here.
<to be read again>
\unitlength
l.19 \put(200pt,100pt){My report}
I was expecting to see \hbox or \vbox or \copy or \box or
something like that. So you might find something missing in
your output. But keep trying; you can fix this later.


One more question: how to make the title in the middle of the page using \put? I tried to use

Code: Select all

\put(\pagewidth/2,100pt){My report}
but not working.

Thanks in advance!
Last edited by Stefan Kottwitz on Tue Jan 17, 2012 1:20 am, edited 2 times in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Re: Rotate and put text

Post by cgnieder »

Please provide a MWE (see my signature) that let's us reproduce the error. Then we can help much faster and easier!

Regards
site moderator & package author
buzon
Posts: 7
Joined: Tue Jan 17, 2012 1:08 am

Rotate and put text

Post by buzon »

Hi, here's the MWE (without the graphic file, but works anyway)

Code: Select all

\documentclass[a4paper]{article}
\usepackage[absolute]{textpos}
\usepackage{graphicx}
\usepackage{rotating}

\def\text-title{My report}

\title{\text-title \\ 
		\large \vspace*{-10pt} with colored headings and special fonts\vspace*{10pt}}

\begin{document}

\newpage
\thispagestyle{empty}

\begin{turn}{-45}
\put(200pt,100pt){My report}
\end{turn}

\begin{textblock*}{\paperwidth}(0mm,0mm)
   \noindent\includegraphics[width=\paperwidth,height=\paperheight]{gfx/front.png}
\end{textblock*}
\mbox{}\newpage

\end{document}

thanks!
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Rotate and put text

Post by cgnieder »

I recognise two errors in your code:
  • You cannot use \put outside the picture environment.
  • the coordinates of \put cannot be specified in pt but only in multiples of \unitlength
I am not sure why you're using \put, anyway, but I'm guessing you're trying to position something on the page.

Code: Select all

\documentclass{article}
\usepackage{graphicx}
\begin{document}
\begin{picture}(210,297)(0,0)
 \put(105,200){\rotatebox{-45}{\huge My report}}
\end{picture}
\end{cocument}
picture.jpg
picture.jpg (4.79 KiB) Viewed 13104 times
Another way might be using TikZ/pgf instead:

Code: Select all

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[remember picture,overlay]% needs at least two compilation runs!
 % gray background:
 \fill[gray!10] (current page.north west) rectangle (current page.south east);
 % or image background:
 % \node[anchor=south west] at (current page.south west) {\includegraphics[width=\paperwidth,height=\paperheight]{...};
 % rotated text above the center of the page:
 \draw (current page.center) ++ (0,8cm) node[rotate=-45,scale=4] { My report };
\end{tikzpicture}
\end{document}
tikzpicture.jpg
tikzpicture.jpg (3.63 KiB) Viewed 13104 times
Regards
site moderator & package author
buzon
Posts: 7
Joined: Tue Jan 17, 2012 1:08 am

Re: Rotate and put text

Post by buzon »

Works like a charm, thanks! :)
Btw - your assumption was correct: I want to position text, but I'd prefer to avoid using absolute coordinates and take some more flexible approach - i.e. at 70% of page width (my picture is to fullfill whole page). What would you recommend for this?

thanks again for you help!
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Rotate and put text

Post by cgnieder »

You could for example replace the line of my TikZ-code

Code: Select all

\draw (current page.center) ++ (0,8cm) node[rotate=-45,scale=4] { My report };
by this one

Code: Select all

\draw (current page.south) ++ (0,.7\paperheight) node[rotate=-45,scale=4] { My report };
current page.south would mean the center of the lower page border. ++(0,.7\paperheight) would shift that point up by 70% of the paper height.
site moderator & package author
Post Reply