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'm trying to import author list to my latex article. But keep getting errors. Here is my code:

\documentclass{article}
\usepackage{verbatim}
\title{\verbatiminput{title.txt}}
\author{\verbatiminput{authors.txt}}
\date{\verbatiminput{date.txt}}
\begin{document}
   \maketitle
   Hello world!
\end{document}

and the authors.txt

ya zhang

and I got this error:

! LaTeX Error: Something's wrong--perhaps a missing \item.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.7    \maketitle

? 

Can anyone help? Thanks a lot.

share|improve this question

migrated from stackoverflow.com Jun 27 '13 at 1:42

This question came from our site for professional and enthusiast programmers.

1  
Welcome to TeX.SX! Your post was migrated here from another Stack Exchange site. Please register on this site, too, and make sure that both accounts are associated with each other (by using the same OpenID), otherwise you won't be able to comment on or accept answers or edit your question –  texenthusiast Jun 27 '13 at 5:23

1 Answer 1

up vote 2 down vote accepted

Use \input rather than \verbatiminput:

enter image description here

\documentclass{article}
\usepackage{filecontents,verbatim}% http://ctan.org/pkg/{filecontents,verbatim}
\begin{filecontents*}{authors.txt}
ya zhang
\end{filecontents*}
\title{My title}%\title{\input{title.txt}}
\author{\input{authors.txt}}
\date{\today}%\date{\input{date.txt}}
\begin{document}
   \maketitle
   Hello world!
\end{document}

If you wish to format the title with different fonts (the only gain from using something like \verbatiminput, without more detail provided), you can supply that as part of the arguments:

\title{\ttfamily My title}
%...
share|improve this answer
    
that works, Thanks a lot. –  user2522104 Jun 26 '13 at 15:47
    
I'm wondering why the author element can't use verbatiminput? The title and date elements works well. Could you tell me? –  user2522104 Jun 26 '13 at 15:51
    
@user2522104: The author is handled differently than the title and date. The latter two are set as-is, while the former is set inside a tabular, where some characters have special meaning. The only reason to use \verbatiminput would be if you require special symbols to be interpreted in the regular way (which should not be the case with authors). –  Werner Jun 26 '13 at 16:57
    
I see, Thanks a lot. –  user2522104 Jun 28 '13 at 20:54

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.