Text Formattinggetting the length of a string?

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
jay1990
Posts: 1
Joined: Fri Sep 11, 2009 10:49 am

getting the length of a string?

Post by jay1990 »

Hi all. I'd just like to know if theres a Latex function that i can use to retrieve the number of characters in a string. Eg:

\begin{document}

\strlen{test}

\end{document}

would print "4" on the page. Does something like that exist?

Cheers.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

getting the length of a string?

Post by localghost »

This is definitely a job for the xstring package. Refer to Section 2.3 (Macros returning a number, p. 9ff) of the manual.


Best regards and welcome to the board
Thorsten
Post Reply