Why the packages subfig, babel-slovene and TikZ don't like each other?

The problem is that the babel TikZ library solves the problem of the " shorthand by changing its category code when tikzpicture begins. However, when the tikzpicture is in the argument to \subfloat, this category code cannot be changed.

Solutions: use subcaption or patch \subfloat to do \scantokens:

\documentclass{memoir}
%---------------------------------------------------------------%
\usepackage[english,slovene]{babel}
%---------------------------------------------------------------%
\usepackage{lmodern}
\usepackage{ragged2e}
\usepackage[
  labelsep=space,
  labelfont={sf,bf},
  textfont=sf,
  justification=RaggedRight,
  caption=false
]{subfig}
\usepackage{etoolbox}
\makeatletter
\patchcmd{\sf@@@subfloat}{#4}{\scantokens{#4\empty}}{}{}
\makeatother
%---------------------------------------------------------------%
\usepackage{tikz}
\usetikzlibrary{
  angles,
  quotes,
  babel
}


\tikzset{
  MA/.style args = {#1/#2}{% My Angle label position!
    draw, <->,
    angle radius=#1,
    angle eccentricity=#2},
  every pic quotes/.append style = {inner sep=1pt, anchor=west},
}
%---------------------------------------------------------------%

\begin{document}

\begin{figure}[h]\centering
\subfloat[\label{fig:1.39a}]{%
  \begin{tikzpicture}
  %---
  \draw[->]   (-1mm,0) -- (44mm,0) coordinate (B);
  \draw[->]   (0,-1mm) -- (0,33mm);
  %---
  \draw[thick,->]
    (0,0)       coordinate (O) --
    (60:33mm)   coordinate (A);
  \pic [MA=11mm/1.1,"$\omega_c t+\varphi$",red] {angle = B--O--A};
  %----------------
  \end{tikzpicture}
}\quad
\subfloat[\label{fig:1.39br}]{%
  %%%%    ht-138b (bandpass signal)
  \begin{tikzpicture}
  %---
  \draw[->]   (-1mm,0) -- (44mm,0) coordinate (B);
  \draw[->]   (0,-1mm) -- (0,33mm);
  %---
  \draw[thick,->]
    (0,0)       coordinate (O) --
    (60:33mm)   coordinate (A);
  \pic [MA=12mm/1.15,"$\varphi$",red] {angle = B--O--A};
  %----------------
  \end{tikzpicture}
}
\caption{Xyz}

\end{figure}

\end{document}

enter image description here


You should use the newer package subcaption package instead of subfig, and replace \subfloat{...} with the subfigure environment:

\documentclass{memoir}
%---------------------------------------------------------------%
\usepackage[english,slovene]{babel}
%---------------------------------------------------------------%
\usepackage{lmodern}
\usepackage{ragged2e}
\usepackage[labelsep=space,
            labelfont={sf,bf},
            textfont=sf,
            justification=RaggedRight]{subcaption}
%---------------------------------------------------------------%
\usepackage{tikz}
\usetikzlibrary{
  angles,
  quotes,
% added for compatibility with babel ...
  babel
}
\usepackage[active,floats,tightpage]{preview}
\setlength\PreviewBorder{1em}
\tikzset{
  MA/.style args = {#1/#2}{% My Angle label position!
    draw, <->,
    angle radius=#1,
    angle eccentricity=#2},
  every pic quotes/.append style = {inner sep=1pt, anchor=west},
}
%---------------------------------------------------------------%
\begin{document}

\begin{figure}[h]\centering
  \begin{subfigure}{0.49\textwidth}
    \centering
    \begin{tikzpicture}
      % ---
      \draw[->]   (-1mm,0) -- (44mm,0) coordinate (B);
      \draw[->]   (0,-1mm) -- (0,33mm);
      % ---
      \draw[thick,->]
      (0,0)       coordinate (O) --
      (60:33mm)   coordinate (A);
      \pic [MA=11mm/1.1,"$\omega_c t+\varphi$",red] {angle = B--O--A};
      % ----------------
    \end{tikzpicture}
    \caption{}
    \label{fig:1.39a}
  \end{subfigure}
  \hfill
  \begin{subfigure}{0.49\textwidth}
    \centering
    %%%% ht-138b (bandpass signal)
    \begin{tikzpicture}
      % ---
      \draw[->]   (-1mm,0) -- (44mm,0) coordinate (B);
      \draw[->]   (0,-1mm) -- (0,33mm);
      % ---
      \draw[thick,->]
      (0,0)       coordinate (O) --
      (60:33mm)   coordinate (A);
      \pic [MA=12mm/1.15,"$\varphi$",red] {angle = B--O--A};
      % ----------------
    \end{tikzpicture}
    \caption{}
    \label{fig:1.39br}
  \end{subfigure}
  \caption{}
\end{figure}

\end{document}

Output