# Generate a square and line

how should i write a command to automatically place a box on the left side wherein this box can contain text and beside the box are lines which depends on an argument.

-
Can you please describe in more detail the desired result? Should the framed box have fixed height and width? –  Gonzalo Medina Nov 26 '12 at 16:35
Do you want the box (and lines) be break across pages? –  Aditya Nov 26 '12 at 16:50

Without more details about the width and height of the framed box and a MWE, this is a raw answer:

\documentclass{article}
\usepackage{pgffor}
%\usepackage{setspace}
\newcommand\leftbox[1]{%
\par\noindent
\begin{minipage}[t]{.45\textwidth}
\fbox{%
\parbox[t][5cm]{\dimexpr\textwidth-2\fboxrule-2\fboxsep}{%
#1}%
}%
\end{minipage}%
}%
\newcommand\lines[1]{%
\hfill
\begin{minipage}[t]{.45\textwidth}%
\noindent
\foreach \x in {1,...,#1}{%
\rule{\textwidth}{1pt}\\[1em]}%
\end{minipage}%
}%
\begin{document}
\leftbox{text will be placed here inside this box with a frame}\lines{4}
\end{document}


The pgffor package can be avoided by using (Thanks to Gonzalo):

\newcounter{lines}
\newcommand\lines[1]{%
\hfill
\begin{minipage}[t]{.45\textwidth}%
\loop \ifnum\value{lines}<#1\relax
\rule{\textwidth}{1pt}\\[1em]
\stepcounter{lines}%
\repeat
\end{minipage}
}

-

There are various possibilities for the alignment, but something like this

\documentclass{article}

\long\def\leftbox#1{\fbox{\parbox[t]{.4\textwidth}{#1}}}
\def\lines#1{\parbox[t]{.4\textwidth}{\par%
\count0=#1
\vskip-\ht\strutbox
\loop
\vskip\baselineskip
\hrule width\hsize
\ifnum\count0>0
\repeat}}

\begin{document}

\leftbox{The text goes here\\
and here\\
and here}
\lines{4}

\end{document}

-