-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapptexviewer.html
190 lines (147 loc) · 6.74 KB
/
apptexviewer.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
<!doctype html>
<html lang="pt">
<head>
<meta charset="utf-8">
<title>LaTex View Page</title>
<script type="text/javascript" id="MathJax-script" defer
src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-svg.js">
</script>
<script>
MathJax = {
tex: {
inlineMath: [['$', '$'], ['\\(', '\\)']]
},
svg: {
fontCache: 'global'
}
};
</script>
<style>
body {margin: 0; padding: 0;}
#page-app {width: 100%; display: grid; padding:0; text-align: center; font-family: arial, sans-serif;}
#app-wview {display: grid; background-color: #c5c5c5;color: white; width: 100%; height: auto; padding: 6% 0 8% 0; font-weight: bold; font-size: 22pt;}
#wview{color: black;background-color: whitesmoke; padding: 10pt; height: auto; margin: 2pt;}
#app-box-in { width: auto; height: auto; padding: 4px 2px 25px 2px; margin: 1% 10% 0 15%; background-color: whitesmoke; border: 1px solid white; box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);}
#app-tex-code {display: grid; border: none; margin: 2pt 8pt 0 8pt; }
#app-tex-code textarea { grid-row: 1; grid-column: 1 / span 2; border: none; /*box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);*/ }
/* Buttons "Render" and "Save (Render to Printer)"*/
#btn { grid-row: 2; float: center; border: none; padding: 4pt; color: #18465f; font-size: 12pt;background-color: #c5c5c5; border-radius: 8px; text-decoration: none; }
#btn:hover { background-color: gray; }
#tex-input { color: #18465f; appearance: none; resize: none;}
</style>
</head>
<body>
<div id="page-app">
<div id="app-wview">
LaTex View
<div id="app-box-in">
<div id="app-tex-code">
<textarea id="tex-input" name="textarea" placeholder="Your Tex Code" rows="20" cols="80"></textarea>
<a href="#tex-out" id="btn" onclick="convert()">Render</a>
<a href="#" id="btn" onclick="saveprint()">Save (Render to Printer)</a>
</div>
</div>
</div>
<div id="wview">
<div style="margin: 0; width: auto; height: auto; padding: 4pt; background-color: white;">
Doação/Donate
<br /><br>
<div style="margin: 10px; padding: 8px; ">
<a style="color: black;" href="https://wsricardo.blogspot.com/p/apoie-como-contribuir.html">Como apoiar? Support</a>
</div>
</div>
<div style="width: 40%; height: 30px; padding: 4px; margin: 2% 35% 0 30% ; border-radius: 4px 4px 0 0; background-color: #839dab; color: white; font-size: 12pt;">Viewer Window</div>
<div id="tex-out" style=" white-space: pre-wrap; margin: 0 0 0 0; width: auto; height: auto; padding: 18px; font-size: 16pt; text-align: left; background-color: #c5d0d6; border-radius: 8px; box-shadow: #bbbbbb 2px 4px 8px 1px;">
<br>
<b>Calculo - Limite</b>
<br><br>
<span style="font-weight: bold;" >Definição</span>: Seja \(f\) uma função cujo domínio \(D\subset \mathbb{R}^2\) contém pontos arbitrariamente próximos de \((a,b)\). Dizemos que o limite de \(f(x,y)\) quando \((x, y)\) tende a \((a, b)\) é \(L\) e escrevemos
<br><br>
\[\lim_{(x,y) \to (a,b)} f(x,y) = L\]
<br>
se para todo número \(\epsilon > 0\) existe um número correspondente \(\delta > 0\) tal que se \((x, y) \in D\) e \(0 < \sqrt{(x-a)^2 + (y - b)^2} < \delta\) então \(|f(x, y) - L| < \epsilon\).
<br><br><br>
<u>Exemplo</u>: Verificar que \(\lim_{(x,y) \to (0,0)} \frac{3x^2y}{x^2 + y^2} = 0\).
<br>
Seja \(\epsilon > 0\), queremos determinar um \(\delta > 0\) tal que se
\(0 < \sqrt{x^2+y^2} < \delta\) então \(|\frac{3x^2y}{x^2+y^2}| < \epsilon\)
<br>
Considerando \(x^2 > 0\) e \(y^2 > 0\), como \(x^2+y^2 > 0\) e \(3x^2y>0 \; se \; y\geq 0 \; e \; 3x^2y < 0 \; se \; y < 0\) com \((x, y) \in D \subset \mathbb{R}^2\), temos que se
\(0 < \sqrt{x^2 + y^2} < \delta \; então \; \frac{3x^2|y|}{x^2+y^2} < \epsilon\)
<br><br>
Como \(y^2 \geq 0\) logo \(x^2+ y^2 \geq x^2\) assim \(\frac{x^2}{x^2+y^2} \leq 1\) e portanto
<br><br>
\[\frac{3x^2|y|}{x^2+y^2} \leq (3|y|) = 3\sqrt{y^2} < 3\sqrt{x^2+ y^2}\]
<br>
Como, se \(3\sqrt{x^2 + y^2} < \epsilon\) logo \(\frac{3x^2|y|}{x^2+y^2} < \epsilon\) assim se escolhermos \(\delta = \frac{\epsilon}{3}\) e fizermos \(0 < \sqrt{x^2+y^2} < \delta\) tal que,
\(3\sqrt{x^2+y^2} < \epsilon\) de forma que \(\frac{3x^2|y|}{x^2+y^2} < \epsilon\) obtendo-se \(\sqrt{x^2 + y^2} < \frac{\epsilon}{3}\).
<br>
Assim se escolhermos \(\delta = \frac{\epsilon}{3}\) e fizermos \(0 < \sqrt{x^2+ y^2} < \delta\) teremos,
<br>
\[|\frac{3x^2y}{x^2+y^2}| < 3\sqrt{x^2+y^2} < 3 \delta = 3(\frac{\epsilon}{3}) = \epsilon\]. \(\square\)
</div>
</div>
</div>
<footer style="margin: 10px; padding: 8px; text-align: center; ">Blog <a href="https://wsricardo.blogspot.com">WSRicardo</a></footer>
<script>
// Pre-process and prepare to rende latex.
async function convert() {
// Reg is regular expressions to replace new line
let reg_newline = /(\w+|.+|\n+)(\\newline)+(\n|\w+)/;
let reg_breakline = /(\w+|.+|\n+)(\\breakline)+(\n|\w+)/;
console.log("called!");
var text = document.getElementsByTagName("textarea");
var out = document.getElementById("tex-out");
out.innerHTML = "";
out_text = text["textarea"].value.replace(reg_newline, "\n".toString());
out_text = out_text.replace(reg_breakline, "\n".toString() );
console.log('>text ', text['textarea'].value);
var tagcontent = document.createTextNode(out_text);
out.insertAdjacentHTML("beforeend", out_text);
console.log('>> ', out_text);
console.log(">", out.outerText);
//console.log("post> ", post);
MathJax.typeset( );
}
// Prepare for print in browser.
async function saveprint(){
console.log("save called!");
var text = document.getElementsByTagName("textarea");
const out_content = document.createTextNode( text["textarea"].value );
var out = document.createElement("div");
document.body.innerHTML = "";
document.body.style="padding: 12px; font-size: 22pt; margin: 8px; color: black; width: auto;";
out.append( out_content );
document.body.append(out);
out.setAttribute( "onload", "print();" );
//console.log("value textarea ", out );
MathJax.typeset();
}
async function checkParamURL( ) {
// If param text in url insert latex text in texfield and render latex.
const textField = document.querySelector("textarea");
const url = new URL( window.location.href )
const sParam = url.searchParams
//const text = sParam.get( "text" )
// The string "//" mean "space" in text for use share link in plataforms that change "space"
// for the code "%20" of char "+".
const text = decodeURI( url.search.split('?text=')[1] ).replaceAll("\\", " ");
// If parameter "text" passed in URL.
if ( url['href'].search( "text=" ) !== -1 ) {
if (text[0] === '"' && text[ text.length - 1 ] == '"' ){
textField.value = text.slice( 1, -1 );
} else {
textField.value = text;
}
await convert();
//console.log('if text');
return text;
} else {
//console.log("else text");
return "Insert yout LaTex text";
}
}
checkParamURL();
</script>
</body>
</html>