2

I'm trying to write a code which exports a series of ten "block" characters. I refer to the character 219 in the ascii table. Imagine having such character instead of "a" in the following MWE.

\documentclass[11pt, a4paper]{article}

\usepackage{ifthen}

\newcounter{WrittenWords}
\newcounter{WrittenCharacters}

\begin{document}

\setcounter{WrittenWords}{0}%
\whiledo{\value{WrittenWords}<50}{%
    \addtocounter{WrittenWords}{1}%
    \setcounter{WrittenCharacters}{0}%
    \whiledo{\value{WrittenCharacters}<11}{%
        \addtocounter{WrittenCharacters}{1}%
        a%
    }
}

\end{document}

I tried to copy-paste it, but it doesn't work because I'm working with utf-8 alphabet and apparently it doesn't contain that character.

I tried to use the pmboxdraw package and the \textlfblock command, and it works, but it puts a space between characters. I want them to be attached.

The same goes if I use the \amdsymbol package and the \blacksquare command.

I came to discover, in this answer to an other question, the existence of the command \char, after which I should put a code. I tried to use \char32 instead of 'a' in the code above, and in fact it works in printing that weird character in the way that I want. The issue is that I don't understand where to find the number of my block character. I tried to play with \char and as much as I understood the number I must put in front of it is not the decimal number of the character, nor the hex number of it. I didn't find anywhere an explaination of such command which linked to a table with the numbers I needed.

  • Related question: here? – TeXnician May 12 '17 at 15:46
  • @TeXnician I passed there, in fact. What destroys me is the "if you know the code" conditional in the answer. I don't know it and I'd like to know how to know it. – il mietitore May 12 '17 at 15:54
  • @egreg The table says 219, thought, and in fact if I look for "ascii 219" on google it comes out: google.it/…. 235 is the accented u: google.it/… – il mietitore May 12 '17 at 15:55
  • \textlfblock creates a 'left block', which from the name implies it is a 'half-block' on the left and space on the right (per character). Why not use the \textblock command which creates blocks spanning the full character width? Then there won't be spaces between consecutive characters? – Troy May 12 '17 at 15:56
  • Curious. This works. I didn't think that the blank space resulting was cause by that "half white" part. I thoght it just was thinner – il mietitore May 12 '17 at 15:58
3

Here's a possible 'hacky' solution using \blacksquare from the AMS package (if you want to avoid conflict between textpos and pmboxdraw packages).

$\blacksquare\!$% with amssymb package

I think unlike in the case of \textblock, \blacksquare has white spacing as seen from using \fbox. They are also of different sizes, so you might take that into account, depending on your purpose.

\fboxsep=0pt
\fbox{$\blacksquare$} % left
\fbox{\textblock} % right

enter image description here

Anyway, to get around this with \blacksquare, I found that using \! to get rid of the spacing works. So a complete code with output:

\documentclass[11pt, a4paper]{article}
\usepackage{amssymb}% <------------
\usepackage{ifthen}

\newcounter{WrittenWords}
\newcounter{WrittenCharacters}

\begin{document}
    \noindent
    \setcounter{WrittenWords}{0}%
    \whiledo{\value{WrittenWords}<50}{%
        \addtocounter{WrittenWords}{1}%
        \setcounter{WrittenCharacters}{0}%
        \whiledo{\value{WrittenCharacters}<11}{%
            \addtocounter{WrittenCharacters}{1}%
            $\blacksquare\!$% <------------
        }
    }
\end{document}

black squares

0

As pointed out by the user Troy, in the case of the package pmboxdraw the space between the single characters was caused by the chosen character being an half-block (\textlfblock) instead of a full one (\textblock). By using \textblock the characters actually appear one at the side of the other.

I had some troubles in the main document I'm working on, where a name clash issue arose with the package textposwhich already defined the command \textblock. The solution, taken from the response to this similar question, was to use the code \let\textblock\relax after loading the package textpos, but before loading the package pmboxdraw. This probably might give issues in cases which require the original textblock command from the package textpos, but for me this is now working.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.