4

I am typesetting my lecture notes and need to highlight some entries in the matrices, to indicate which entries I am talking about. In two out of three matrices the highlighting is exactly where it should be, but in the third the highlighting is off. The two red dots should be highlighting the 1s in the 1st and 2nd column of the third matrix.
I ran the code several times (aware that if the position of the matrices changed, it takes one more run for tex to create correct coordinates for the highlighting). I also deleted the other files (all except the .tex one) to make sure that was not what was creating a problem. Now I don't know what else to try.
Could someone please tell me what is wrong with my code? Thanks! Image of the code output

\noindent\begin{minipage}{\textwidth}
\vspace{0.3cm}
\noindent\begin{minipage}[b]{.32\textwidth}
\begin{tabular}{c}
$
\begin{bmatrix}
1 & \tikzmark{notleadingone}{1} \\
0 & 1 \\
0 & 0 \\
0 & 0
\end{bmatrix} $
\begin{tikzpicture}[overlay,remember picture]
 \draw[opacity=.2,line width=4mm,line cap=round,color=red]   (notleadingone.center) -- (notleadingone.center);\end{tikzpicture} \\
 \\
\begin{tabular}{ c }
There is a nonzero\\ entry in a column \\ of a leading 1 \\
\end{tabular}
\end{tabular}
\end{minipage}
\begin{minipage}[b]{.32\textwidth}
\begin{tabular}{c}
$\begin{bmatrix}
                           \tikzmark{leftzerorow}{0} & 0 & 0 &    \tikzmark{rightzerorow}{0} \\
                           0 & 1 & 0 & 0 \\
                           0 & 0 & 1 & 0 \\
                           0 & 0 & 0 & 0
                         \end{bmatrix}$ \begin{tikzpicture} [overlay,remember picture]
 \draw[opacity=.2,line width=4mm,line cap=round,color=red]  (leftzerorow.center) -- (rightzerorow.center);\end{tikzpicture}\\
 \\
\begin{tabular}{ c }
Not all \\ zero rows\\ are at the bottom \\
\end{tabular}
\end{tabular}
 \end{minipage}
\begin{minipage}[b]{.32\textwidth}
\begin{tabular}{c}
  $\begin{bmatrix}
                                                      0 & 0 & 1 \\
                                                         \tikzmark{oneone}{1} & 0 & 0 \\
                                                      0 & \tikzmark{twoone}{1} & 0 \\
                                                      0 & 0 & 0
                                                    \end{bmatrix}$ 
                                                    \begin{tikzpicture} 
                                                    \draw[opacity=.2,line width=4mm,line cap=round,color=red] (oneone.center) -- (oneone.center);
                                                    \draw[opacity=.2,line width=4mm,line cap=round,color=red] (twoone.center) -- (twoone.center);\end{tikzpicture} \\
  \\
  \begin{tabular}{ c }
 Some leading 1s are \\not to the right from \\ the leading 1s above them   \\
  \end{tabular}
  \end{tabular}
   \end{minipage}
 \end{minipage}
  • 1
    Welcome to TeX.SX! Please help us help you and add a minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – Stefan Pinnow May 26 '17 at 5:27
  • 6
    Your third tikzpicture is missing the remember picture,overlay options. – Loop Space May 26 '17 at 5:37
3

Firstly, I'm afraid I can't test your code without the preamble - in particular, your version of \tikzmark doesn't look like it's from the current version on CTAN, but I can't be sure.

Nevertheless, I can spot something obvious and (from the comments) it would appear that this is the missing bit. The tikzpictures that provide the highlight all need to have the remember picture,overlay options applied and the third doesn't.

Incidentally, with the latest version of tikzmark from CTAN you can put the highlighting code before the \tikzmark so that the highlighting appears under the text rather than over it.

  • Thank you so much for the answer, @LoopSpace. I didn't even realize that highlighting was done over the text. I tried to put the highlighting before, but got a message "package pgf error: no shape named shape's label is known". Does this mean that the version of tex that I have is not the latest one? – Nataliya Laptyeva May 28 '17 at 16:45
  • @NataliyaLaptyeva That probably means you're using an old version of tikzmark. If you post a mwe, I can take a look. – Loop Space May 28 '17 at 18:39

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.