3

I am triying to write my thesis in Latex. I want to create a title page. In my title page i have some space with the texts. I tried to give it with \vspace but it works between text not from top of the page. Can you suppose me a way to do this?

enter image description here

3
  • Thank you @ChristianHupfer :) . I try it but it only create between two text but i want to give space from top of the page for every text or line. Jan 9, 2016 at 16:26
  • 1
    (la)tex processes material in a stream; it doesn't start from the top of the page for each new line. although it's possible to make that happen, it's generally easier to determine how much space is required between lines to achieve the desired "drop", and specify that smaller \vspace where needed. Jan 9, 2016 at 16:31
  • But this is a template. Sometime my text can be 2 or 3 lines. For example i want to start second text everytime from 10 cm below the top of the page. Jan 9, 2016 at 16:46

5 Answers 5

7

In order to add space at the top of the page you have to say

\vspace*{3cm}

because the simple \vspace is removed at page breaks.

If you want precise positioning with respect to the page margins, you can use textpos. For instance

\documentclass{book}
\usepackage{textpos}

\newcommand{\fromtop}[1]{%
  \dimexpr-1in-\topskip-\topmargin-\headheight-\headsep+#1\relax
}
\newcommand{\fromleft}[1]{%
  \dimexpr-1in-\oddsidemargin+#1\relax
}

\begin{document}

\begin{titlepage}
\setlength{\parindent}{0pt}

\begin{textblock*}{0pt}(\fromleft{2cm},\fromtop{3cm})
\makebox[0pt][l]{Text at the top}
\end{textblock*}

\begin{textblock*}{\textwidth}(\fromleft{5cm},\fromtop{6.5cm})
\makebox[0pt][l]{Text in the middle}
\end{textblock*}

\begin{textblock*}{\textwidth}(\fromleft{3cm},\fromtop{9.5cm})
\makebox[0pt][l]{Text at the bottom}
\end{textblock*}

\end{titlepage}

\end{document}

enter image description here

Another example, for centering the texts with respect to the page borders:

\documentclass{book}
\usepackage{textpos}

\newcommand{\fromtop}[1]{%
  \dimexpr-1in-\topskip-\topmargin-\headheight-\headsep+#1\relax
}
\newcommand{\fromleft}[1]{%
  \dimexpr-1in-\oddsidemargin+#1\relax
}

\begin{document}

\begin{titlepage}
\setlength{\parindent}{0pt}

\begin{textblock*}{\paperwidth}(\fromleft{0cm},\fromtop{3cm})
\centering
Text at the top
\end{textblock*}

\begin{textblock*}{\paperwidth}(\fromleft{0cm},\fromtop{6.5cm})
\centering
Text in the middle\\
with new line
\end{textblock*}

\begin{textblock*}{\paperwidth}(\fromleft{0cm},\fromtop{9.5cm})
\centering
Text at the bottom\\
with new line
\end{textblock*}

\end{titlepage}

\end{document}

enter image description here

6
  • 1
    while true, this only takes care of positioning the first line. Jan 9, 2016 at 19:11
  • @barbarabeeton You're right. I have added a full solution, which does positioning with respect to the page borders, contrary to all others that have been presented.
    – egreg
    Jan 9, 2016 at 20:42
  • I try this. But i cant unerstand how can i insert a new line in one block. For example text \\ text \\ text . 3 text is in same block but the one under the other. And also how can i make it center position Jan 9, 2016 at 22:18
  • @CengizGörkemDENGİZ Your question didn't have those details. I added another example
    – egreg
    Jan 9, 2016 at 22:25
  • Thank you for your answer this also solved problem. And two more question. Can i include pragraph indent in this block. And can i change text width and line spacing for only one block. Jan 9, 2016 at 23:05
5

I find tikzpagenodes to be perfect for laying out title pages. Note, you need to run this twice.

\documentclass{article}
\usepackage{tikzpagenodes}
\usetikzlibrary{calc}
\usepackage{mwe}

\begin{document} 
\thispagestyle{empty}% I assume you don't want a page number
\begin{tikzpicture}[remember picture,overlay]
\draw[red] (current page text area.south west) rectangle (current page text area.north east);
\node[below,inner sep=0pt,text width=\textwidth] at ($(current page.north)+(0,-3cm)$)
  {Notice that 3 cm is actually above the text area.};
\node[below,inner sep=0pt,text width=\textwidth] at ($(current page.north)+(0,-6.5cm)$)
  {This should be 6.5 cm below the top of the page.};
\node[below,inner sep=0pt,text width=\textwidth] at ($(current page.north)+(0,-9.5cm)$)
  {This should be 9.5 cm below the top of the page.};
\end{tikzpicture}
\newpage
\end{document}

title page

4

The accepted answer is overcomplicated and with one potential bug. Try to write "Plus text text text" instead "Text text text" and think about the error message:).

What you need is something like this:

\newenvironment{mytextbox}[1]
    {\nointerlineskip \vbox to 0pt\bgroup\vskip#1\relax}
    {\vss\egroup}

Note: you need not to allocate special box, you need not to correct the vertical positions when \nointerlineskip is used.

1
  • I fixed the missing \relax bug in mine, thanks I always forget those. It's especially annoying in cases like \advance\mycounter1\ifnum\mycounter<10\dosomething\fi where the test happens with the old value... Jan 9, 2016 at 19:02
1

Try this:

\newbox\mybox
\newenvironment{mytextbox}[1]
    {\vskip-\baselineskip\setbox\mybox=\vbox\bgroup\vskip#1\relax}
    {\egroup\ht\mybox=0pt\box\mybox}

At the beginning of the environment it starts a box and puts the appropriate vertical space at the top of it. The body of the environment goes into the box, and then at the end it sets the height to zero and prints the box. You probably will need to end the page using \newpage.

Example:

\documentclass{article}
\newbox\mybox
\newenvironment{mytextbox}[1]
    {\vskip-\baselineskip\setbox\mybox=\vbox\bgroup\vskip#1}
    {\egroup\ht\mybox=0pt\box\mybox}

\begin{document}
\begin{mytextbox}{3cm}
Text text text Text text text Text text textText text textText text textText text text
Text text textText text text Text text textText text textText text text
\end{mytextbox}


\begin{mytextbox}{6.5cm}
Text text text Text text textText text textText text textText text textText text text
Text text text Text text textText text textText text text
\end{mytextbox}
\end{document} 

Edit: Thanks to Wipet for catching a dumb mistake in my code. I recommend anyone who wants to use this environment to use Wipet's better answer further down on this page.

7
  • Yes it worked. Thank you! But when i try to second text for 0 cm it add a baselineskip. Can i type {-\baselineskip + 5cm} or else. Jan 9, 2016 at 17:09
  • If you want to adjust everything up by a \baselineskip, replace the second line of the environment definition with: {\setbox\mybox=\vbox\bgroup\vskip-\baselineskip\vskip#1}. On my computer, it seems that the space is slightly less than a \baselineskip. Jan 9, 2016 at 17:10
  • If you try {0cm} for two textbox there are some space. So it is not top to top distance. Jan 9, 2016 at 17:19
  • I see, so you need to say {\vskip=-\baselineskip \setbox\mybox=\vbox\bgroup\vskip#1}. This makes it so that multiple 0pt boxes lie directly on top of each other. Jan 9, 2016 at 17:24
  • Yes can you fix it in example please. Jan 9, 2016 at 17:27
-1
\documentclass{article}
\newbox\mybox
\newenvironment{mytextbox}[1]
{\vskip-\baselineskip\setbox\mybox=\vbox\bgroup\vskip#1}
{\egroup\ht\mybox=0pt\box\mybox}
\begin{document}
\begin{titlepage}
\begin{center}
\begin{mytextbox}{0.5cm}
    \textbf{asdf\\
    asdf ÜNİVERSİTESİ\\
    FEN BİLİMLERİ ENSTİTÜSÜ}
\end{mytextbox}
\begin{mytextbox}{4cm}
    \textbf{asdgd ANABİLİM DALI}
\end{mytextbox}
\begin{mytextbox}{7cm}
    \textbf{adfhdsh}
\end{mytextbox}
\begin{mytextbox}{12.5cm}
    \textbf{DOKTORA TEZİ}\\
\end{mytextbox}
\begin{mytextbox}{13.5cm}
    \textbf{asfsdgd}\\
    \textbf{124235}
\end{mytextbox}
\begin{mytextbox}{17cm}
    \textbf{Tezin Savunma Tarihi: 00.00.0000}
\end{mytextbox}
\begin{mytextbox}{20.5cm}
    \textbf{Tez Danışmanı: asgsdggf}
\end{mytextbox}    
\end{center}
\begin{mytextbox}{24cm}
 Bu Yüksek Lisans/Doktora Tez Çalışması sagfdfhgdh Üniversitesi………………’nolu Proje ile desteklenmiştir.
\end{mytextbox}
\end{titlepage}
\end{document} 

I typed this command and it worked. I dont understand wipet answer.

1
  • 2
    The answer is low-quality. All you did was grab the definition of the accepted answer and included it in your use-case. It's adding unnecessary clutter to this post.
    – Werner
    Jan 9, 2016 at 19:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .