
Eu uso oMiamifonte para simular pequenos trechos de texto manuscritos (algumas linhas). Como a fonte é bastante clara, uso uma adaptação deSteven B. Segletessolução de Como colocar texto caligráfico personalizado em negrito
- O problema é que, dando
\BODY
como\calbf
argumento, engole todas as quebras de linha. (Mas ele lida bem com caracteres UTF-8 com tremas alemães etc.). Isso não tem nada a ver com a fonte miama. A quebra de linha também é afetada sem ela. Também me pergunto sobre o fato de que chamar
\calbf
conforme mostrado na última linha (comentada), gera este erro:! Erro de entrada do pacote: sequência de bytes UTF-8 inválida.
Veja a documentação do pacote inputenc para explicação. Digite H para ajuda imediata. ...
l.61 ...á é ó í ú \ldots \"e \"i \"a \"o \"u} insira o código aqui
Alguém pode me mostrar como lidar (especialmente) com o problema 1?
\documentclass[12pt]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{environ}
\usepackage[scale=1]{miama}
\usepackage{stackengine}
\def\useanchorwidth{T}
\def\stacktype{L}
\def\stackalignment{l}
\def\calup{.2pt}
\def\calover{.15pt}
\def\calbf#1{\calbfhelpA#1 \relax\relax}
\def\calbfhelpA#1 #2\relax{%
\calbfhelpB#1\relax\relax%
\ifx\relax#2\else\ \calbfhelpA#2\relax\fi
}
\def\calbfhelpB#1#2\relax{%
\stackon[\calup]{#1}{\kern\calover#1}%
\ifx\relax#2\else
\calbfhelpB#2\relax%
\fi
}
\NewEnviron{MyCal}%
{%
\fmmfamily%
\noindent%
\calbf{Test0}\\ \BODY \\\\ \calbf{\BODY}%
}
\begin{document}
\def\calup{.3pt}
\def\calover{.3pt}
\begin{MyCal}
MyCal:\\
Test1: ä.ö.ü.Ä.Ö.Ü.ß.\ss.
\par
á é ó í ú
\"e \"i \"a \"o \"u
\end{MyCal}
\par\vspace{1em}
%\calbf{ä.ö.ü.Ä.Ö.Ü.ß.\ss \ldots á é ó í ú \ldots \"e \"i \"a \"o \"u}
\end{document}
Responder1
Tente isso para o problema 1. Não entendo o suficiente sobre o problema 2 para tentar resolvê-lo.
O principal problema era que a versão original \calbf
não tinha nenhum controle de expansão. Então o que aconteceu foi que \calbf
vi um único token \BODY
e simplesmente o passei e disse \stackon[\calup]{\BODY}{\kern\calover\BODY}
. O motivo pelo qual \calbf
tenta passar um token por \calup
vez é provavelmente devido ao fato de que passar um bloco inteiro de texto destrói a quebra de linha.
Portanto, mudar \calbf
para expandir seu argumento ajuda. Eu uso o \romannumeral
truque para expandir recursivamente o primeiro token de \calbfhelpA
. Nesse caso, o primeiro token é \BODY
e se expande e despeja o resto de tudo.
Surge então outro problema: a única razão pela qual funcionou dizer \"a
antes foi porque \calbf
não foi possível separar com êxito os caracteres individuais da entrada porque estava tudo em \BODY
. A correção requer testes internos para saber \calbfhelpB
se o primeiro argumento é uma macro. Se o primeiro argumento for uma macro, salve-o e pegue também o próximo token. Também teremos problemas se virmos um token \par
ou \\
, por isso os testamos separadamente.
\documentclass[12pt]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{environ}
\usepackage[scale=1]{miama}
\usepackage{stackengine}
\def\useanchorwidth{T}
\def\stacktype{L}
\def\stackalignment{l}
\def\calup{.2pt}
\def\calover{.15pt}
\makeatletter
% Terminal token to signal end of input.
% We give it a unique definition so that `\ifx\endtoken\anythingelse` always tests false.
% Since we're using fexpansion, we need an extra `\noexpand` to prevent it from getting
% turned into something else.
\def\calbf@endtoken{\noexpand\calbf@endtoken}
% Use \romannumeral trick to "f expand" argument
% We are going to parse by spaces, so we need to add a terminal space and \relax
% so we can tell when we are done.
\def\calbf#1{\expandafter\calbf@\romannumeral-`0#1 \calbf@endtoken}
% Needs to be \long in case argument is a \par token.
% #1 - a single word
\long\def\calbf@#1 {%
\calbf@handleword{}#1\calbf@endtoken
% Check if we are done. If not, fexpand rest of input and recurse.
\@ifnextchar\calbf@endtoken{}{\ \expandafter\calbf@\romannumeral-`0}%
}
% Helper macro to test for equality.
\long\def\calbf@ifx#1#2{%
\ifx#1#2\expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi
}
% Test if argument is a macro (checks if \string#1 contains multiple characters).
\long\def\calbf@ifmacro#1{%
\expandafter\ifx\expandafter$\romannumeral-`0\expandafter\@gobble\string#1$%
\expandafter\@secondoftwo
\else
\expandafter\@firstoftwo
\fi
}
\long\def\calbf@handleword#1#2{%
\calbf@ifx{#2}{\calbf@endtoken}{}{% we're done with this word
\calbf@ifx{#2}{\par}{%
#2\calbf@handleword{}% just pass \par tokens through
}{%
\calbf@ifx{#2}{\\}{%
#2\calbf@handleword{}% just pass \\ tokens through
}{%
\calbf@ifmacro#2{% If it's an accent, save it and grab the argument too.
\calbf@handleword{#1#2}%
}{%
\stackon[\calup]{#1{#2}}{\kern\calover#1{#2}}% Otherwise print it.
\calbf@handleword{}%
}%
}}}%
}
\NewEnviron{MyCal}{%
%\fmmfamily
\noindent
\calbf{Test0}\\ \BODY \\\\
\calbf{\BODY}%
}
\makeatother
\begin{document}
\def\calup{.3pt}
\def\calover{.3pt}
\"{ab}
\begin{MyCal}
MyCal:\\
Test1: %ä.ö.ü.Ä.Ö.Ü.ß.\ss.
\par
abcd
\"e \"i \"a \"o \"u \"e\"i\"a\"o\"u \"{abcd} {1234}
\end{MyCal}
\par\vspace{1em}
%\calbf{ä.ö.ü.Ä.Ö.Ü.ß.\ss \ldots á é ó í ú \ldots \"e \"i \"a \"o \"u}
\end{document}