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 not aware of having a text with a colon and a line as a command. Is this possible? I am using the exam document class so I can use the \question command for the proper numbering.

example:

 \documentclass{exam}
 \begin{document}
 \begin{questions}
     \question{Good} \oolonline
     \question{happy} \colonline
     \question{sad} \colonline
     \question{nervous} \colonline
     \question{angry} \colonline
 \end{questions}

 \end{document}

and it will appear like this:

enter image description here

share|improve this question
    
It looks like the colons are supposed to be aligned, except when the word on the left is too long. Is that what you have in mind? –  Charles Staats Dec 11 '12 at 16:19
    
Is this what you are looking for: \newcommand{\colonline}[1]{\question{#1\,:\rule{75pt}{0.4pt}}} –  azetina Dec 11 '12 at 16:34

3 Answers 3

up vote 5 down vote accepted

Using the exam class, you can have the following:

enter image description here

\documentclass{exam}
\usepackage{multicol}
\newcommand{\colonline}[1]{\question{#1\,:\rule{75pt}{0.4pt}}}
\begin{document}
\begin{multicols}{2}
 \begin{questions}
    \colonline{Good}
    \colonline{Happy}
    \colonline{Sad}
    \colonline{Nervous}
    \colonline{Good}
    \colonline{Happy}
    \colonline{Sad}
    \colonline{Nervous}
    \colonline{Good}
    \colonline{Happy}
    \colonline{Sad}
    \colonline{Nervous}
    \colonline{Good}
    \colonline{Happy}
    \colonline{Sad}
    \colonline{Nervous}
    \colonline{Good}
    \colonline{Happy}
    \colonline{Sad}
    \colonline{Nervous}
    \colonline{Good}
    \colonline{Happy}
    \colonline{Sad}
    \colonline{Nervous}
    \colonline{Good}
    \colonline{Happy}
    \colonline{Sad}
    \colonline{Nervous}
 \end{questions}
\end{multicols}
\end{document}

You can use the multicol package to split the questions in two columns if there are more than 30 questions. If you want it in a command like format, you can use:

\newcommand{\synquestions}[2][2]{%
\begin{multicols}{#1}
\begin{questions}
#2
\end{questions}
\end{multicols}
}

and implement it like this:

\synquestions{%
    \colonline{Good}
    \colonline{Happy}
    \colonline{Sad}
    \colonline{Nervous}
    }
share|improve this answer
    
If the number of question for example is 30 numbers no longer fil for one page, how would it be let to second column instead? –  Kayla Dec 11 '12 at 17:17
    
@kayla see my updated answer. –  azetina Dec 11 '12 at 18:32

Something like that?

\documentclass{exam}

\usepackage{tikz}
\newcommand{\colonline}[1][2cm]{: \tikz[baseline={([yshift=0.3ex]current bounding box.center)}]{\draw (0,0) -- (#1,0);}} 

\begin{document}

\begin{questions}
  \question{Good} \colonline
  \question{happy} \colonline
  \question{sad} \colonline
  \question{nervous} \colonline
  \question{angry} \colonline
\end{questions}

\end{document}

enter image description here

Edit : For the follow-up question you asked in comment, you can use an alternative questions environment defined with help of the multicol package.

\documentclass{exam}

\usepackage{tikz}
\newcommand{\colonline}[1][2cm]{: \tikz[baseline={([yshift=0.3ex]current bounding box.center)}]{\draw (0,0) -- (#1,0);}} 

\usepackage{multicol}

\newenvironment{manyquestions}{\begin{multicols}{2}\begin{questions}}{\end{questions}\end{multicols}}

\begin{document}

\begin{manyquestions}
  \question{Good} \colonline
  \question{happy} \colonline
  \question{sad} \colonline
  \question{nervous} \colonline
  \question{angry} \colonline
  \question{Good} \colonline
  \question{happy} \colonline
  \question{sad} \colonline
  \question{nervous} \colonline
  \question{angry} \colonline
  \question{Good} \colonline
  \question{happy} \colonline
  \question{sad} \colonline
  \question{nervous} \colonline
  \question{angry} \colonline
  \question{Good} \colonline
  \question{happy} \colonline
  \question{sad} \colonline
  \question{nervous} \colonline
  \question{angry} \colonline
  \question{Good} \colonline
  \question{happy} \colonline
  \question{sad} \colonline
  \question{nervous} \colonline
  \question{angry} \colonline
  \question{Good} \colonline
  \question{happy} \colonline
  \question{sad} \colonline
  \question{nervous} \colonline
  \question{angry} \colonline
  \question{Good} \colonline
  \question{happy} \colonline
  \question{sad} \colonline
  \question{nervous} \colonline
  \question{angry} \colonline
  \question{Good} \colonline
  \question{happy} \colonline
  \question{sad} \colonline
  \question{nervous} \colonline
  \question{angry} \colonline
  \question{Good} \colonline
  \question{happy} \colonline
  \question{sad} \colonline
  \question{nervous} \colonline
  \question{angry} \colonline
\end{manyquestions}

\end{document}
share|improve this answer
    
@Verron: how would I let this one lane proceed to a new column to prevent its continuation to the next page? example the question goes up to 30 plus number of question. for it to not proceed to the next page, how will I make this proceed to 2nd column? –  Kayla Dec 11 '12 at 17:07
    
@kayla : I editted to include a solution. However, such follow-up questions should be asked as a separate question, to maintain a clear Q/A interface for the site. –  T. Verron Dec 11 '12 at 17:45

Something simpler if you are not after the alignment of the \colonlines

\documentclass{exam}

\newcommand{\colonline}{: \makebox[0.75in]{\hrulefill}}

\begin{document}

\begin{questions}
     \question{Good} \colonline
     \question{happy} \colonline
     \question{sad} \colonline
     \question{nervous} \colonline
     \question{angry} \colonline
 \end{questions}

\end{document}

As suggested by morbusg, it looks nicer to have the line align at the end.

\documentclass[twocolumn]{exam}

\newcommand{\colonline}{: \hrulefill}

\begin{document}

\begin{questions}
     \question{Good} \colonline
     \question{happy} \colonline
     \question{sad} \colonline
     \question{nervous} \colonline
     \question{angry} \colonline
 \end{questions}

\end{document}

You can combine the answers here to come up with your own command. Generally, the definition of commands in LaTeX is given by:

\newcommand{<command>}{<definition>}

In our second definition of \colonline, \colonline is the command and what it does is to print : \hrulefill.

Sometimes, you can also see something like

\newcommand{\bt}[1]{\textbf{#1}} where 1 is the number of optional arguments. (I usually do \newcommand{\bt}[1]{\textbf{#1}\index{#1}} so that all bold text are put in the index.)

It would be a good place to start reading The Not So Short Introduction to LaTeX2e to learn some of these useful tricks.

share|improve this answer
    
Maybe it would be nice to even go one step further and drop the makebox, leaving just the \hrulefill so it uses the whole horizontal space, thus aligning at end; used with two columns should work well overall. –  morbusg Dec 11 '12 at 19:43

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.