2

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}
2
  • 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. Commented Mar 30, 2012 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. Commented Mar 30, 2012 at 1:02

1 Answer 1

1

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.

2
  • Peter and Stephan, thank you very much for the help. The truncate package does the job. Commented Mar 30, 2012 at 18:10
  • @CaioBolzani In that case, maybe you could accept the question. Commented Mar 30, 2012 at 18:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .