Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am currently working on my thesis report and would like to add affirmation to it. Following is the minimal code for the same :

\documentclass[]{article}
\begin{document}
\section*{Affirmation}
\addcontentsline{toc}{section}{Affirmation}
\hspace{1cm}something
\vspace{2cm}
\hspace{1cm}city, date \hspace{3cm}\line(1,0){200}
\newline
\hspace{8cm}(name)
\clearpage
\end{document}

It produces the following outputThe output image

As it can be seen, the (name) should come below the line, But due to some reason the \hspace before (name) isn't working.

Any help would in this regards would be really appreciated.

share|improve this question
    
Could it be that your picture wasn’t generated by this code? –  doncherry Apr 21 '13 at 16:31
    
No, It was generated by the code mentioned above. –  Kishore pandey Apr 21 '13 at 16:33
    
Your code cannot produce this output because \vspace doesn’t do anything in the paragraph context you put it in. I pasted your code to writeLaTeX without changing anything, have a look: writelatex.com/151831vwvhtx. It seems to me that your screen shot was taken before you reduced your document to a MWE. –  doncherry Apr 21 '13 at 16:37

2 Answers 2

up vote 9 down vote accepted

What your code does

From the unofficial LaTeX reference manual, sec. 20.1:

LaTeX normally removes horizontal space that comes at the beginning or end of a line. To preserve this space, use the optional * form [of \hspace].

So let’s use \hspace* instead:

\documentclass[]{article}
\begin{document}
    \section*{Affirmation}
    \addcontentsline{toc}{section}{Affirmation}
    \hspace{1cm}something
    \vspace{2cm}
    \hspace{1cm}city, date \hspace{3cm}\line(1,0){200}
    \newline
    \hspace*{8cm}(name)
    \clearpage
\end{document}

output

What your picture says

The rest of the spacing is pretty different from your output because your screen shot was quite certainly not produced by the code you posted. With a bit of guesswork, I think this is closer to what you intended (note that you have to use the starred version of \hspace in several instances):

\documentclass{article}
\begin{document}
\section*{Affirmation}
\addcontentsline{toc}{section}{Affirmation}
\hspace*{1cm}something

\vspace{2cm}

\noindent\hspace*{1cm}city, date \hspace{3cm}\line(1,0){200}
\newline
\noindent\hspace*{8cm}(name)
\end{document}

output

What I would suggest

Taking your layout and thinking about an implementation, I would do something like this, which is cleaner than meddling with a lot of spacing manually:

\documentclass{article}
\begin{document}
\section*{Affirmation}
\addcontentsline{toc}{section}{Affirmation}

something\\[2cm]
city, date \hfill
\begin{minipage}[t]{7cm}\centering
    \rule{\linewidth}{.5pt}\\
    (name)
\end{minipage}

\end{document}

output

share|improve this answer
    
Thank you so much. That was really useful and it's working too :) –  Kishore pandey Apr 21 '13 at 16:30
    
@Kishorepandey Glad it helps. I added some more details to my answer. –  doncherry Apr 21 '13 at 16:53

As @doncherry said you can fix the problem using the starred version \hspace*{}. But I'm giving here an alternative solution to you to produce a line to sign. I usually use it.

\begin{flushright}
\begin{minipage}{6cm}
\begin{center}
\hrulefill\\
(date)
\end{center}
\end{minipage}
\end{flushright}

enter image description here

share|improve this answer
1  
Thanks a lot for sharing this. –  Kishore pandey Apr 21 '13 at 16:34

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.