public static String prepareAlignatMath(final String input) {
        String tmp = input.replace("\\begin{align}", "\\begin{alignat}{2}");
        tmp = tmp.replace("\\end{align}", "\\end{alignat}");
        tmp = tmp.replaceAll("\\\\pmod", "&&\\\\pmod");
        tmp = tmp.replaceAll("÷", "\\\\div");
        
        final StringBuilder sb = new StringBuilder(256);
        try {
            final BufferedReader bufReader = new BufferedReader(new StringReader(tmp));
            String line;
            while ((line = bufReader.readLine()) != null) {
                if (line.split("&").length == 2)
                    line = line.replace("\\\\", " &&\\\\");
                sb.append(line).append(NEWLINE);
            }
        } catch (IOException ex) {
            System.err.println(ex.getMessage());
        }
        return sb.toString();
    }