## LaTeX forum ⇒ Text Formatting ⇒ coolstr Topic is solved

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
kabenyuk
Posts: 2
Joined: Sun Feb 03, 2019 10:09 am

### coolstr

Hi. dear frend!
This is my question.
I'm trying to use the coolstr package. Like this.
coolstr_expl.tex

\documentclass[10pt]{article}\usepackage{coolstr} \newcommand{\simv}[2]{     \ifstrchareq{#1}{#2}{A}{10}{      \ifstrchareq{#1}{#2}{B}{11}{       \ifstrchareq{#1}{#2}{C}{12}{        \substr{#1}{#2}{1}}}}} \begin{document} \simv{C2A3B}{1}\simv{C2A3B}{2}\simv{C2A3B}{3}\simv{C2A3B}{4}\simv{C2A3B}{5} \end{document}

However, instead of 12210311 I get this: 12 2 10 3 11
coolstr_expl.pdf

For some reason, there are extra spaces.
What am I doing wrong?
Thank!
Best regards!

kabenyuk

Stefan Kottwitz
Posts: 9285
Joined: Mon Mar 10, 2008 9:44 pm
Hi kabenyuk,

welcome to the forum!

The end of the line is considered as a space. In the document code, If a word is at the end of a line and another word follows on the next line, there will be a space in the output between the words. Since line ends are considered as a space, macro authors very often add a percent sign at the end of the line to comment that space out. That's how you can fix it, comment out the line end by %:

\documentclass[10pt]{article}\usepackage{coolstr} \newcommand{\simv}[2]{%\ifstrchareq{#1}{#2}{A}{10}{%\ifstrchareq{#1}{#2}{B}{11}{%\ifstrchareq{#1}{#2}{C}{12}{%\substr{#1}{#2}{1}}}}} \begin{document} \simv{C2A3B}{1}%\simv{C2A3B}{2}%\simv{C2A3B}{3}%\simv{C2A3B}{4}%\simv{C2A3B}{5} \end{document}

Stefan