1

Is it possible to get a regular optic at the algorithm package when using the uarial package?

I am using:

%change font
\usepackage{uarial}
%set arial as default font for everything
\renewcommand\familydefault{\sfdefault}

And a regular:
% Algorithm
\usepackage{algorithm}% http://ctan.org/pkg/algorithms
\usepackage{algpseudocode}% http://ctan.org/pkg/algorithmicx
\makeatletter
\renewcommand*{\ALG@name}{Algorithmus}
\makeatother
\MakeRobust{\Call}

But do get some "not nice" optic out of this:

\begin{algorithm}[H]
    \caption{Insert Funktion}\label{alg:insert}
    \begin{algorithmic}[1]
        \Function{insert}{$json$,$prev$}
            \State $prev \gets prev$  
            \ForAll{Element $e$ in $json$}
                \State $position \gets \Call{find}{\Call{size}{e}}$ \Comment{finde Position für $e$}

                \State Erzeuge ein neues Objekt an der Position mit dem jeweiligen Datentypen. new(position) BaseTyp<type(e)>(e)

                \If{prev != null}
                    \State $ prev\rightarrow next \gets \Call{distance}{prev,position}$\Comment{ Vorgänger Next Wert anpassen}
                \EndIf
            \EndFor
            \State füge Headerinformation in den Header ein
            \State füge Headerposition mit Page ID in den Objekt Index ein
        \EndFunction
    \end{algorithmic}
\end{algorithm}

enter image description here

Any way to get uarial to be as expected here or to get a font at algorithm which can handle that properly and looks simelar to uarial (no seriefs)?

  • \usepackage[scale]{tgheros} instead of \usepackage{uarial}. – egreg Nov 15 '15 at 17:23
  • great! i dont know what the package does but i is as expected! Thanks alot! – BennX Nov 15 '15 at 17:26
  • But i am confused, i can use it beside uarial and have the regular Arial font at text and also textsc at the algorithm and still have arial in the algorithm. Beside the tgheros does have seriefs – BennX Nov 15 '15 at 17:28
  • Ah got it. I override the uarial with the include. Thanks! – BennX Nov 15 '15 at 17:32
1

The uarial font has no small caps, as far as I know. You can use tgheros that has and is based on Helvetica, very similar to Arial.

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}

\usepackage{amsmath}

\usepackage[scale]{tgheros}

%set arial as default font for everything
\renewcommand\familydefault{\sfdefault}

\usepackage{algorithm}% http://ctan.org/pkg/algorithms
\usepackage{algpseudocode}% http://ctan.org/pkg/algorithmicx

\makeatletter
\renewcommand*{\ALG@name}{Algorithmus}
\makeatother
\MakeRobust{\Call}

\begin{document}

\begin{algorithm}
\caption{Insert Funktion}\label{alg:insert}
\begin{algorithmic}[1]
  \Function{insert}{json,prev}
    \State $\text{prev} \gets \text{prev}$  
    \ForAll{Element e in json}
      \State $\text{position} \gets \Call{find}{\Call{size}{\text{e}}}$ \Comment{finde Position für e}

      \State Erzeuge ein neues Objekt an der Position mit dem jeweiligen Datentypen. 
        new(position) BaseTyp<type(e)>(e)

      \If{prev != null}
        \State $ \text{prev}\rightarrow \text{next} \gets \Call{distance}{\text{prev},\text{position}}$%
          \Comment{Vorgänger Next Wert anpassen}
      \EndIf
    \EndFor
    \State füge Headerinformation in den Header ein
    \State füge Headerposition mit Page ID in den Objekt Index ein
  \EndFunction
\end{algorithmic}
\end{algorithm}

\end{document}

enter image description here

If you also want accompanying math fonts, you can use newtxsf:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}

\usepackage{amsmath}

\usepackage[scale]{tgheros}
\usepackage{newtxsf}

%set arial as default font for everything
\renewcommand\familydefault{\sfdefault}

\usepackage{algorithm}% http://ctan.org/pkg/algorithms
\usepackage{algpseudocode}% http://ctan.org/pkg/algorithmicx

\makeatletter
\renewcommand*{\ALG@name}{Algorithmus}
\makeatother
\MakeRobust{\Call}

\begin{document}

\begin{algorithm}
\caption{Insert Funktion}\label{alg:insert}
\begin{algorithmic}[1]
  \Function{insert}{\textit{json},\textit{prev}}
    \State $\textit{prev} \gets \textit{prev}$  
    \ForAll{Element e in json}
      \State $\textit{position} \gets \Call{find}{\Call{size}{e}}$ \Comment{finde Position für $e$}

      \State Erzeuge ein neues Objekt an der Position mit dem jeweiligen Datentypen. 
        new(position) BaseTyp<type($e$)>($e$)

      \If{$\textit{prev} \mathrel{!}= \textit{null}$}
        \State $ \textit{prev}\rightarrow \textit{next} \gets 
          \Call{distance}{\textit{prev},\textit{position}}$%
          \Comment{Vorgänger Next Wert anpassen}
      \EndIf
    \EndFor
    \State füge Headerinformation in den Header ein
    \State füge Headerposition mit Page ID in den Objekt Index ein
  \EndFunction
\end{algorithmic}
\end{algorithm}

\end{document}

enter image description here

| improve this answer | |

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.