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 wrote the \bib command to reference authors in my thesis not using numeric or alpha references of natbib. It copies a piece of text, cut the first 60 characters (the width of my page} and put it together with the bibentry in the end of my work. Everything goes ok if there is no macros. I've used xstring and tried to expand, not expand...but I could not make it work. I appreciate any help.

\newcommand{\bib}[2]{#1 \pagenote{\cuttext{#1}}\bibentry{#2}}}

\newcommand{\cuttext}[1]{%
\expandarg\StrLeft{#1}{60}[\myleft]%
\expandarg\exploregroups\StrCount{\myleft}{ }[\mycount]%
\StrPosition[\mycount]{\myleft}{ }[\mypos]%
\StrLeft{\myleft}{\mypos}%
}%

Usage in the middle of my thesis text:

\bib{According to \citeauthor{last:2010} the best \textit{rock band singer} was bla bla bla}{last:2010}
share|improve this question
    
Welcome to TeX.SE. A tip: If you indent lines by 4 spaces, then they're marked as a code sample. You can also highlight the code and click the "code" button ({}). I took the liberty to format you post a little. See this link for more details on available formatting. –  Peter Grill Mar 30 '12 at 1:01
    
Also, while code snippets are useful in explanations, it is always best to compose a fully compilable MWE that illustrates the problem including the \documentclass and the appropriate packages so that those trying to help don't have to recreate it. –  Peter Grill Mar 30 '12 at 1:02
add comment

1 Answer

up vote 1 down vote accepted

It's really hard to say anything definitive without MWE, but from the description of xstring, I doubt it can be made to work with commands like \citeauthor. It explicitly states in the doc to work with "strings of tokens".

I'd advise trying the truncate package.

share|improve this answer
    
Peter and Stephan, thank you very much for the help. The truncate package does the job. –  Caio Bolzani Mar 30 '12 at 18:10
    
@CaioBolzani In that case, maybe you could accept the question. –  Stephan Lehmke Mar 30 '12 at 18:49
add comment

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.