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.

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.

share|improve this question
    
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

2 Answers 2

up vote 4 down vote accepted

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}

enter image description here

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}
}
share|improve this answer

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

enter image description here

\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
\advance\count0 -1
\ifnum\count0>0
\repeat}}

\begin{document}

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

\end{document}
share|improve this answer

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.