Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggested Example on Concatenating LaTeX Output #114

Open
alsaibie opened this issue Sep 12, 2020 · 1 comment
Open

Suggested Example on Concatenating LaTeX Output #114

alsaibie opened this issue Sep 12, 2020 · 1 comment

Comments

@alsaibie
Copy link

It would be useful to include, in the documentation, an example on concatenating latex terms, such as when generating a state-space representation in LaTeX given the A,B,C matrices.

This is an example (Is this the best way to do it?)

using Latexify

function Latexify_ss(A, B, C)
    return string("\$\\dot{x}=", latexarray(A), "x+", latexarray(B), "u \\\\ [2mm] ", "y=", latexarray(C), "x\$")
end

A = [1 0; 0 1];
B = [1; 0];
C = [1 0];

println.(Latexify_ss(A,B,C));

Output:

$\dot{x}=\left[
\begin{array}{cc}
1 & 0 \\
0 & 1 \\
\end{array}
\right]x+\left[
\begin{array}{c}
1 \\
0 \\
\end{array}
\right]u \\ [2mm] y=\left[
\begin{array}{cc}
1 & 0 \\
\end{array}
\right]x$

image

@gustaphe
Copy link
Collaborator

I would do something like this:

julia> latexalign([L"\dot{x}", :y], [:($A*x+$B*u),:(C*x)])
L"\begin{align}
$\dot{x}$ =& \left[
\begin{array}{cc}
1 & 0 \\
0 & 1 \\
\end{array}
\right] \cdot x + \left[
\begin{array}{c}
1 \\
0 \\
\end{array}
\right] \cdot u \\
y =& C \cdot x
\end{align}
"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants